From e1576d2360b5606c1c0ffe6e5cdb0213ff71f9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=20Pr=C3=A9vost-Corvellec=20Arnault?= Date: Wed, 8 Apr 2026 21:27:27 +0200 Subject: [PATCH] Update Dockerfile and configuration files to use port 8080 and improve caching --- server/Dockerfile | 24 +++++++++++++++++++-- server/nginx/default.conf | 2 +- talks-slides-dist/templates/deployment.yaml | 3 ++- talks-slides-dist/values.yaml | 4 ++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 94b34b9..5cba54a 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,6 +1,9 @@ +# syntax=docker/dockerfile:1 +# BuildKit / buildx : cache apk + permissions posées au build (moins de travail / capabilities au runtime). FROM nginx:alpine -RUN apk add --no-cache git +RUN --mount=type=cache,target=/var/cache/apk \ + apk add --no-cache git WORKDIR /usr/share/nginx/html @@ -19,6 +22,23 @@ RUN find . -mindepth 1 -delete \ COPY nginx/default.conf /etc/nginx/conf.d/default.conf COPY refresh.sh /refresh.sh -RUN chmod +x /refresh.sh + +# Caches et logs : créés ici avec le même schéma que l’entrypoint nginx (évite le chown au démarrage). +# Propriétaire nginx (cf. /etc/nginx/nginx.conf user) → l’entrypoint ne refait pas chown si tout est déjà cohérent. +RUN chmod +x /refresh.sh \ + && mkdir -p \ + /var/cache/nginx/client_temp \ + /var/cache/nginx/proxy_temp \ + /var/cache/nginx/fastcgi_temp \ + /var/cache/nginx/uwsgi_temp \ + /var/cache/nginx/scgi_temp \ + /var/log/nginx \ + && chown -R nginx:nginx \ + /var/cache/nginx \ + /var/log/nginx \ + /usr/share/nginx/html + +# Port non privilégié (pas de CAP_NET_BIND_SERVICE) ; le Service K8s mappe souvent 80 → 8080. +EXPOSE 8080 CMD sh -c "/refresh.sh & exec nginx -g 'daemon off;'" diff --git a/server/nginx/default.conf b/server/nginx/default.conf index 59ed759..0f58c41 100644 --- a/server/nginx/default.conf +++ b/server/nginx/default.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen 8080; server_name localhost; # Racine web = contenu statique sparse (dossier content/ du dépôt). root /usr/share/nginx/html/content; diff --git a/talks-slides-dist/templates/deployment.yaml b/talks-slides-dist/templates/deployment.yaml index 3a6671f..2e07433 100644 --- a/talks-slides-dist/templates/deployment.yaml +++ b/talks-slides-dist/templates/deployment.yaml @@ -32,12 +32,13 @@ spec: imagePullPolicy: {{ .Values.slides.image.pullPolicy }} securityContext: allowPrivilegeEscalation: false + # Port 8080 dans le conteneur : pas besoin de NET_BIND_SERVICE (ports privilégiés). capabilities: drop: ["ALL"] readOnlyRootFilesystem: false ports: - name: http - containerPort: 80 + containerPort: {{ .Values.slides.containerPort }} protocol: TCP livenessProbe: httpGet: diff --git a/talks-slides-dist/values.yaml b/talks-slides-dist/values.yaml index 27edbc0..e65f9a2 100644 --- a/talks-slides-dist/values.yaml +++ b/talks-slides-dist/values.yaml @@ -14,8 +14,12 @@ slides: replicaCount: 1 + # Port d’écoute dans le conteneur (doit correspondre à server/nginx/default.conf, ex. 8080). + containerPort: 8080 + service: type: ClusterIP + # Port du Service (Ingress pointe ici) ; le trafic est envoyé vers containerPort sur les pods. port: 80 resources: