fix(dockerfile-fontend)
This commit is contained in:
@@ -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 <<EOF /entrypoint.sh
|
||||
#!/bin/sh
|
||||
if [ "\$MODE" = "dev" ]; then
|
||||
echo "🔧 Mode DEVELOPPEMENT"
|
||||
exec npm run dev -- --host 0.0.0.0 --port 8080
|
||||
else
|
||||
echo "🚀 Mode PRODUCTION"
|
||||
exec nginx -g "daemon off;"
|
||||
fi
|
||||
EOF
|
||||
|
||||
RUN chmod +x /entrypoint.sh
|
||||
RUN echo '#!/bin/sh' > /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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user