From 94b6155c68dc8d55b0c0dd73724370c1ffe3bddd Mon Sep 17 00:00:00 2001 From: Damien Mercier Date: Tue, 14 Apr 2026 17:06:10 +0200 Subject: [PATCH] Fix language switche, adapt contact form and add gitea action. --- .dockerignore | 4 + .env.template | 12 +-- .gitea/workflows/build_and_deploy.yaml | 94 +++++++++++++++++++ Dockerfile | 33 ++----- compose.yaml | 23 +++++ hugo.toml | 3 +- .../chill-theme/layouts/partials/header.html | 2 +- .../layouts/partials/language-switcher.html | 2 +- .../layouts/shortcodes/contact-form.html | 9 +- 9 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build_and_deploy.yaml create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..72d674d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +public +node_modules +.hugo_build.lock +hugo_stats.json \ No newline at end of file diff --git a/.env.template b/.env.template index 7d346f3..ca6f430 100644 --- a/.env.template +++ b/.env.template @@ -1,11 +1 @@ -# Configuration SMTP pour contact-backend.js -BASE_URL=http://localhost -SMTP_HOST=HOST -SMTP_PORT=PORT -SMTP_SECURE=false -SMTP_USER=USER -SMTP_FROM=FROM -SMTP_PASS=PASSWORD -PORT=PORT - - +CONTACT_FORM_URL="http://localhost:1314/contact.php" \ No newline at end of file diff --git a/.gitea/workflows/build_and_deploy.yaml b/.gitea/workflows/build_and_deploy.yaml new file mode 100644 index 0000000..9e8bc34 --- /dev/null +++ b/.gitea/workflows/build_and_deploy.yaml @@ -0,0 +1,94 @@ +name: Build and push chill website image + +on: + # Runs on pushes targeting the default branch + push: + branches: + - main + - master + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Environment variables available to all jobs and steps in this workflow +env: + HUGO_ENV: production + HUGO_VERSION: "0.136.2" + GO_VERSION: "1.21.4" + NODE_VERSION: "18" + KUBE_CA: LS0tLS1CRUdJTiBDRVJUSUZJ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FHV3pmZmVBTFR2ZHlDVkJWdjdHZ1VwWWYwTlRjSVByN0FNWE9lU2YrcWhmUHo1WkYKR2s5aEJIc2dSbGR5cWxKZ1JJcUJuaTZ6OGMwQk42UUtMbDJpMDVqcWxUN2VFalM0WHZhUnUxY0VQUndNZEJYSgp2eWhXOWNZdmh0SEl2aW0zOXRBTkNpK3dUR1ZMd3NRN0NEVmNhck5KRVJJSms2aUhPUXZicVE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + KUBE_SERVER: https://w5v5z4.c1.gra9.k8s.ovh.net + +jobs: + # Build job + build: + runs-on: cth-ubuntu-latest + steps: + - name: Check out repository + uses: https://github.com/actions/checkout@v4 + + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v3 + + - name: Login to registry + uses: https://github.com/docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: 'h3m6q87t.gra7.container-registry.ovh.net' + + - name: Build and push + id: build-push + uses: https://github.com/docker/build-push-action@v5 + with: + context: . + push: true + tags: 'h3m6q87t.gra7.container-registry.ovh.net/chill_website/web:${{ github.ref_name }}' + + - name: Install kubectl + run: | + curl -LO "https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl" + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + + - name: Set up kubeconfig + env: + KUBE_SERVER: ${{ env.KUBE_SERVER }} # e.g. https:// + KUBE_CA: ${{ env.KUBE_CA }} # base64 encoded, or fetched via kubectl config view + KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }} # Token generated via 'kubectl create token' + run: | + mkdir -p ~/.kube + cat < ~/.kube/config + apiVersion: v1 + kind: Config + clusters: + - name: default-cluster + cluster: + server: "$KUBE_SERVER" + certificate-authority-data: "$KUBE_CA" + contexts: + - name: default-context + context: + cluster: default-cluster + user: gitea-actions + current-context: default-context + users: + - name: gitea-actions + user: + token: "$KUBE_TOKEN" + EOF + + - name: Patch Deployment Image + env: + NAMESPACE: chill-website + DEPLOYMENT: chill-website + CONTAINER: front + BASE_IMAGE: 'h3m6q87t.gra7.container-registry.ovh.net/chill_website/web' + TAG_IMAGE: '${{ steps.build-push.outputs.digest }}' + run: | + echo "deploy new tag: $TAG_IMAGE" + env + kubectl -n ${NAMESPACE} set image deployment/${DEPLOYMENT} ${CONTAINER}=${BASE_IMAGE}@${TAG_IMAGE} diff --git a/Dockerfile b/Dockerfile index e9824ca..eb770fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,9 @@ -FROM hugomods/hugo:latest +FROM ghcr.io/gohugoio/hugo:v0.160.0 AS build -# Installe Node.js et npm -USER root -RUN apk add --no-cache nodejs npm git +WORKDIR /project +COPY . /project +RUN hugo build --minify --cleanDestinationDir -WORKDIR /src +FROM caddy:2-alpine -# Copie package.json et package-lock.json si présent -COPY package.json ./ - -# Installation des dépendances -RUN npm install --save-dev sass - -# Copie le reste du code -COPY . . - -# Build CSS (tailwind + scss) -RUN npm run build - - -EXPOSE 1313 3001 - -CMD ["sh", "-c", "set -a; [ -f .env ] && . ./.env; set +a; BASE_URL=${BASE_URL:-http://localhost}; node contact-backend.js & hugo server -D --bind 0.0.0.0 --baseURL ${BASE_URL}:1313 --appendPort=false"] - -# @TODO: Ajouter une étape de build pour générer les fichiers statiques de Hugo -# gunzippé et optimisé pour la production -# utilisé Nginx plutot que serveur -# créer des étapes de build pour la compilation et la copie des fichier sur le serveur nginx -# docker build -t hugo-site:latest . +COPY --from=build /project/public/ /usr/share/caddy/ diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..9ff97f6 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,23 @@ +services: + website: + build: . + ports: + - 1313:80 + env_file: .env + facteur: + image: php:8.5-apache + ports: + - 1314:80 + volumes: + - ./contact-backend/:/var/www/html/ + mailpit: + image: axllent/mailpit + container_name: mailpit + restart: unless-stopped + ports: + - 8025:8025 + - 1025:1025 + environment: + MP_MAX_MESSAGES: 5000 + MP_SMTP_AUTH_ACCEPT_ANY: 1 + MP_SMTP_AUTH_ALLOW_INSECURE: 1 \ No newline at end of file diff --git a/hugo.toml b/hugo.toml index 4a8b894..f483437 100644 --- a/hugo.toml +++ b/hugo.toml @@ -3,6 +3,7 @@ baseURL = "/" title = "" theme = "chill-theme" defaultContentLanguage = "fr" +disableLanguages = ["en", "nl"] # Language configuration [languages] @@ -45,7 +46,7 @@ pagination = { pagerSize = 6, path = "page" } # Security Configuration [security.funcs] - getenv = ['^HUGO_', '^CI$', '^BASE_URL$'] + getenv = ['^HUGO_', '^CI$', '^BASE_URL$', '^CONTACT_FORM_URL$'] # Required Markup Configuration diff --git a/themes/chill-theme/layouts/partials/header.html b/themes/chill-theme/layouts/partials/header.html index dc12708..bf871e6 100644 --- a/themes/chill-theme/layouts/partials/header.html +++ b/themes/chill-theme/layouts/partials/header.html @@ -42,7 +42,7 @@ {{ end }} - {{/* {{ partial "language-switcher" . }} */}} + {{ partial "language-switcher" . }} diff --git a/themes/chill-theme/layouts/partials/language-switcher.html b/themes/chill-theme/layouts/partials/language-switcher.html index ea58149..0041117 100644 --- a/themes/chill-theme/layouts/partials/language-switcher.html +++ b/themes/chill-theme/layouts/partials/language-switcher.html @@ -16,7 +16,7 @@ {{ .LanguageName }} - {{ end }} + {{ end }} {{ end }} diff --git a/themes/chill-theme/layouts/shortcodes/contact-form.html b/themes/chill-theme/layouts/shortcodes/contact-form.html index 3a821ae..f28b372 100644 --- a/themes/chill-theme/layouts/shortcodes/contact-form.html +++ b/themes/chill-theme/layouts/shortcodes/contact-form.html @@ -1,12 +1,9 @@ {{ $form := .Page.Params.contactForm }} -{{ $baseURL := default "http://localhost" (getenv "BASE_URL") }} -{{ $normalizedBaseURL := strings.TrimSuffix "/" $baseURL }} -{{ $defaultContactAction := printf "%s:3001/contact" $normalizedBaseURL }} - +{{ $contactFormUrl := default "https://facteur-cl.sobrietech.be/contact.php" (getenv "CONTACT_FORM_URL") }}
+ action="{{ $form.action | default $contactFormUrl }}" target="_blank">

{{ $form.title }}

{{ range $form.fields }}
@@ -88,7 +85,7 @@ } }) .catch(() => { - showResult('Erreur réseau', false); + showResult('Erreur réseau, veuillez ré-essayer.', false); }); }); });