From 4756c34fd1293d1fa1c6fa5944638152d7e78f79 Mon Sep 17 00:00:00 2001 From: EvanChal Date: Sun, 25 Jan 2026 22:47:36 +0100 Subject: [PATCH] fix(dockerfile-fontend) --- frontend/Dockerfile | 57 +++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 271b517..e6febc5 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -21,7 +21,7 @@ RUN npm run build # Stage 2 : Image finale avec les deux modes FROM node:20-alpine -RUN apk add --no-cache nginx && mkdir -p /etc/nginx/conf.d /run/nginx +RUN apk add --no-cache nginx && mkdir -p /run/nginx WORKDIR /app @@ -34,33 +34,40 @@ COPY . . # Copier le build prod COPY --from=builder /app/dist /usr/share/nginx/html -# Config nginx -RUN echo 'server { \ - listen 8080; \ - root /usr/share/nginx/html; \ - index index.html; \ - location / { \ - try_files $uri $uri/ /index.html; \ +# Config nginx - écrire dans le fichier principal +RUN echo 'worker_processes auto; \ +events { worker_connections 1024; } \ +http { \ + include /etc/nginx/mime.types; \ + default_type application/octet-stream; \ + sendfile on; \ + keepalive_timeout 65; \ + gzip on; \ + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; \ + server { \ + listen 8080; \ + root /usr/share/nginx/html; \ + index index.html; \ + location / { \ + try_files $uri $uri/ /index.html; \ + } \ + location /assets { \ + expires 1y; \ + add_header Cache-Control "public, immutable"; \ + } \ } \ - location /assets { \ - expires 1y; \ - add_header Cache-Control "public, immutable"; \ - } \ -}' > /etc/nginx/conf.d/default.conf +}' > /etc/nginx/nginx.conf # Script d'entrée -COPY < /entrypoint.sh && \ + echo 'if [ "$MODE" = "dev" ]; then' >> /entrypoint.sh && \ + echo ' echo "🔧 Mode DEVELOPPEMENT"' >> /entrypoint.sh && \ + echo ' exec npm run dev -- --host 0.0.0.0 --port 8080' >> /entrypoint.sh && \ + echo 'else' >> /entrypoint.sh && \ + echo ' echo "🚀 Mode PRODUCTION"' >> /entrypoint.sh && \ + echo ' exec nginx -g "daemon off;"' >> /entrypoint.sh && \ + echo 'fi' >> /entrypoint.sh && \ + chmod +x /entrypoint.sh EXPOSE 8080