Prepare docker workflow

This commit is contained in:
kbe
2025-08-19 19:10:43 +02:00
parent ef6876a0d3
commit 40e9660d80
13 changed files with 173 additions and 83 deletions

38
.dockerignore Normal file
View File

@@ -0,0 +1,38 @@
# Hugo build artifacts
.hugo_build.lock
hugo_stats.json
public/
resources/
# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Development files
.editorconfig
.git/
.gitignore
*.md
docs/
# OS files
.DS_Store
Thumbs.db
# Backup files
*.backup
*.bak
*.tmp
# IDE files
.vscode/
.idea/
*.swp
*.swo
*~
# Build artifacts
dist/
build/

27
Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
# Use a Node.js LTS Alpine image as the base
FROM hugomods/hugo:nightly
# Install Node.js and npm (needed for fetch-wordpress.js and sass)
RUN apk add --no-cache nodejs npm
# Install Sass (Dart Sass) globally
RUN npm install -g sass
# Set the working directory inside the container
WORKDIR /app
# Copy the entire project into the container
COPY . .
# Make the build script executable (if not already)
RUN chmod +x scripts/build.sh
# Install Node.js dependencies if any (e.g., for fetch-wordpress.js)
# Assuming package.json exists and has dependencies
RUN if [ -f package.json ]; then npm install; fi
# Ensure /usr/local/bin is in PATH for the CMD
ENV PATH="/usr/local/bin:$PATH"
# Command to run the build script when the container starts
CMD ["./scripts/build.sh"]

29
docker-compose.yml Normal file
View File

@@ -0,0 +1,29 @@
networks:
web:
external: true
services:
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./public:/usr/share/nginx/html:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
restart: unless-stopped
environment:
- NGINX_HOST=localhost
- NGINX_PORT=80
networks:
- web
builder:
build:
context: .
dockerfile: Dockerfile
entrypoint: /bin/sh
volumes:
- .:/app
networks:
- web
# command: ls -l

View File

@@ -7,13 +7,6 @@ ignoreLogs = ["warning-goldmark-raw-html"]
# [permalinks]
# posts = "/:section/:slug/"
[languages]
[languages.fr]
languageCode = 'fr-FR'
languageDirection = 'ltr'
languageName = 'French'
weight = 1
# [taxonomies]
# category = "categories"
@@ -38,8 +31,9 @@ ignoreLogs = ["warning-goldmark-raw-html"]
site = "@mistergeekfrance"
creator = "@mistergeekfrance"
facebook_page = "mistergeekfrance"
# youtube_channel = "UCXXXXXXXXXXXXXXXXXXX"
# Facebook
facebook_page = "mistergeek.fr"
youtube_channel = "UCXXXXXXXXXXXXXXXXXXX"
# Search Engine Verification
# google_verification = "your-google-verification-code"
@@ -47,14 +41,14 @@ ignoreLogs = ["warning-goldmark-raw-html"]
# yandex_verification = "your-yandex-verification-code"
# Local SEO
# [params.seo.local]
# enabled = true
# country = "FR"
# language = "fr"
# region = "Île-de-France"
# city = "Paris"
# latitude = "48.8566"
# longitude = "2.3522"
[params.seo.local]
enabled = true
country = "FR"
language = "fr"
region = "Île-de-France"
city = "Paris"
latitude = "48.8566"
longitude = "2.3522"
# Rich snippets
enable_search_box = true

View File

@@ -6,11 +6,11 @@
<h1 class="fw-normal">{{ .Title }}</h1>
<ul class="list-inline-dash">
{{ if .Params.author }}
<li>Par <a href="/author/{{ .Params.author | urlize }}">{{ .Params.author }}</a></li>
<li>Par <a href="/author/{{ .Params.author | anchorize }}">{{ .Params.author }}</a></li>
{{ end }}
{{ with .Params.categories }}
{{ range . }}
<li>dans <a href="/{{ . | urlize }}">{{ . }}</a></li>
<li>dans <a href="/{{ . | anchorize }}">{{ . }}</a></li>
{{ end }}
{{ end }}
<li> le {{ .Date.Format "02/01/2006" }}</li>
@@ -54,7 +54,7 @@
<h6 class="font-small fw-medium uppercase">Tags</h6>
<ul class="list-inline-sm">
{{ range .Params.tags }}
<li><a href="/tags/{{ . | urlize }}">{{ . }}</a></li>
<li><a href="/tags/{{ . | anchorize }}">{{ . }}</a></li>
{{ end }}
</ul>
</div>

View File

@@ -33,7 +33,7 @@
{{ end }}
<div class="author-card-buttons mt-3">
<div class="author-card-button">
<a href="/author/{{ $author.slug | urlize }}" class="author-button-link" aria-label="Voir les articles de {{ $author.name }}">Voir les articles<svg class="uikit-icon" style="width: 1em;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="var(--c-svg, currentColor)" d="M7.5 4.5V6h9.442L4.5 18.442 5.558 19.5 18 7.058V16.5h1.5v-12z"></path></svg></a>
<a href="/author/{{ $author.slug | anchorize }}" class="author-button-link" aria-label="Voir les articles de {{ $author.name }}">Voir les articles<svg class="uikit-icon" style="width: 1em;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="var(--c-svg, currentColor)" d="M7.5 4.5V6h9.442L4.5 18.442 5.558 19.5 18 7.058V16.5h1.5v-12z"></path></svg></a>
</div>
</div>
</div>

View File

@@ -22,7 +22,7 @@
{{ if .Params.categories }}
{{ $category = index .Params.categories 0 }}
{{ $categorySlug = urlize $category }}
{{ $categorySlug = anchorize $category }}
{{ $categoryUrl = printf "/categories/%s" $categorySlug }}
{{ else if .Section }}
{{ $category = humanize .Section }}
@@ -63,7 +63,7 @@
"@type": "ListItem",
"position": 2,
"name": "{{ if .Params.categories }}{{ index .Params.categories 0 }}{{ else }}{{ humanize .Section }}{{ end }}",
"item": "{{ if .Params.categories }}{{ printf "%s/categories/%s" (absLangURL "") (urlize (index .Params.categories 0)) }}{{ else }}{{ printf "%s/%s" (absLangURL "") .Section }}{{ end }}"
"item": "{{ if .Params.categories }}{{ printf "%s/categories/%s" (absLangURL "") (anchorize (index .Params.categories 0)) }}{{ else }}{{ printf "%s/%s" (absLangURL "") .Section }}{{ end }}"
}{{ end }}
]
}

View File

@@ -2,10 +2,10 @@
{{ if .Params.categories }}
{{ with index .Params.categories 0 }}
{{ if and (eq (printf "%T" .) "string") }}
<a class="font-family-poppins font-small fw-medium uppercase" href="/{{ . | urlize }}">{{ . }}</a>
<a class="font-family-poppins font-small fw-medium uppercase" href="/{{ . | anchorize }}">{{ . }}</a>
{{ else if and (eq (printf "%T" .) "map") }}
{{ if .name }}
<a class="font-family-poppins font-small fw-medium uppercase" href="/{{ .name | urlize }}">{{ .name }}</a>
<a class="font-family-poppins font-small fw-medium uppercase" href="/{{ .name | anchorize }}">{{ .name }}</a>
{{ end }}
{{ end }}
{{ end }}

View File

@@ -27,9 +27,11 @@
{{ if .Site.Data.wordpress }}
{{ $count := 0 }}
{{ range $index, $element := .Site.Data.wordpress.categories }}
{{ if ne $element.name "Featured" }}
<li class="nav-item">
<a class="nav-link" href="/{{ $element.slug }}">{{ $element.name }}</a>
</li>
{{ end }}
{{ end }}
{{ end }}
</ul>

35
nginx.conf Normal file
View File

@@ -0,0 +1,35 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
# Enable gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Main location block
location / {
try_files $uri $uri/ /index.html;
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}

2
package-lock.json generated
View File

@@ -12,7 +12,7 @@
"node-fetch": "^3.3.2"
},
"devDependencies": {
"sass": "^1.90.0"
"sass": "^1.69.5"
}
},
"node_modules/@parcel/watcher": {

20
scripts/build.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
# Exit immediately if a command exits with a non-zero status.
set -e
echo "Building CSS..."
# Assuming sass is installed and available in the environment or Docker image
# Compile theme.scss to theme.css
sass assets/css/scss/theme.scss static/assets/css/theme.css
echo "Fetching content from WordPress..."
# Assuming Node.js is installed and available in the environment or Docker image
node scripts/fetch-wordpress.js
echo "Generating production build with Hugo..."
# Assuming Hugo is installed and available in the environment or Docker image
hugo --minify --environment production --config hugo.toml
echo "Build process completed successfully!"

View File

@@ -2,46 +2,6 @@
# yarn lockfile v1
"@parcel/watcher-android-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz"
integrity sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==
"@parcel/watcher-darwin-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz"
integrity sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==
"@parcel/watcher-darwin-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz"
integrity sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==
"@parcel/watcher-freebsd-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz"
integrity sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==
"@parcel/watcher-linux-arm-glibc@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz"
integrity sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==
"@parcel/watcher-linux-arm-musl@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz"
integrity sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==
"@parcel/watcher-linux-arm64-glibc@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz"
integrity sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==
"@parcel/watcher-linux-arm64-musl@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz"
integrity sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==
"@parcel/watcher-linux-x64-glibc@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz"
@@ -52,21 +12,6 @@
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz"
integrity sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==
"@parcel/watcher-win32-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz"
integrity sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==
"@parcel/watcher-win32-ia32@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz"
integrity sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==
"@parcel/watcher-win32-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz"
integrity sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==
"@parcel/watcher@^2.4.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz"
@@ -201,7 +146,7 @@ readdirp@^4.0.1:
resolved "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz"
integrity sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==
sass@^1.90.0:
sass@^1.69.5:
version "1.90.0"
resolved "https://registry.npmjs.org/sass/-/sass-1.90.0.tgz"
integrity sha512-9GUyuksjw70uNpb1MTYWsH9MQHOHY6kwfnkafC24+7aOMZn9+rVMBxRbLvw756mrBFbIsFg6Xw9IkR2Fnn3k+Q==