fix(dockerfile-fontend)
Some checks failed
Deploy to Development / build-and-deploy (push) Has been cancelled
Deploy to Production / build-and-deploy (push) Successful in 1m46s

This commit is contained in:
EvanChal
2026-01-25 22:47:36 +01:00
parent 2b172c5d34
commit 4756c34fd1

View File

@@ -21,7 +21,7 @@ RUN npm run build
# Stage 2 : Image finale avec les deux modes # Stage 2 : Image finale avec les deux modes
FROM node:20-alpine 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 WORKDIR /app
@@ -34,33 +34,40 @@ COPY . .
# Copier le build prod # Copier le build prod
COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/dist /usr/share/nginx/html
# Config nginx # Config nginx - écrire dans le fichier principal
RUN echo 'server { \ RUN echo 'worker_processes auto; \
listen 8080; \ events { worker_connections 1024; } \
root /usr/share/nginx/html; \ http { \
index index.html; \ include /etc/nginx/mime.types; \
location / { \ default_type application/octet-stream; \
try_files $uri $uri/ /index.html; \ 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 { \ }' > /etc/nginx/nginx.conf
expires 1y; \
add_header Cache-Control "public, immutable"; \
} \
}' > /etc/nginx/conf.d/default.conf
# Script d'entrée # Script d'entrée
COPY <<EOF /entrypoint.sh RUN echo '#!/bin/sh' > /entrypoint.sh && \
#!/bin/sh echo 'if [ "$MODE" = "dev" ]; then' >> /entrypoint.sh && \
if [ "\$MODE" = "dev" ]; then echo ' echo "🔧 Mode DEVELOPPEMENT"' >> /entrypoint.sh && \
echo "🔧 Mode DEVELOPPEMENT" echo ' exec npm run dev -- --host 0.0.0.0 --port 8080' >> /entrypoint.sh && \
exec npm run dev -- --host 0.0.0.0 --port 8080 echo 'else' >> /entrypoint.sh && \
else echo ' echo "🚀 Mode PRODUCTION"' >> /entrypoint.sh && \
echo "🚀 Mode PRODUCTION" echo ' exec nginx -g "daemon off;"' >> /entrypoint.sh && \
exec nginx -g "daemon off;" echo 'fi' >> /entrypoint.sh && \
fi chmod +x /entrypoint.sh
EOF
RUN chmod +x /entrypoint.sh
EXPOSE 8080 EXPOSE 8080