feat(frontend): simplication de la conf nginx + ajout du stage pour le runner dans le dockerfile

This commit is contained in:
ineszang
2026-09-15 11:50:08 +02:00
parent 39b1daea51
commit 8efa034f9c
2 changed files with 66 additions and 2 deletions
+34 -2
View File
@@ -1,5 +1,9 @@
# ==================
# Étape 1 : Build
# ==================
# Image pour frontend # Image pour frontend
FROM node:24-alpine FROM dhi.io/node:24-alpine3.22-dev AS builder
WORKDIR /app WORKDIR /app
@@ -12,4 +16,32 @@ RUN --mount=type=cache,target=/root/.npm npm ci
COPY . . COPY . .
# Build # Build
RUN npm run build RUN npm run build
# ==================
# Étape 2 : Runner
# ==================
FROM dhi.io/nginx:1.28.0-alpine3.21-dev AS runner
# Copie de la configuration de nginx
COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
# Copy the static build output from the build stage to Nginx's default HTML serving directory
COPY --chown=nginx:nginx --from=builder /app/dist/*/browser /usr/share/nginx/html
# Create necessary directories with proper permissions for nginx
RUN mkdir -p /var/log/nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx /var/cache/nginx /usr/share/nginx/html
# Use a non-root user for security best practices
USER nginx
# Frontend : port 3000
# Backend : port 8000
EXPOSE 3000
# Start Nginx directly with custom config
ENTRYPOINT ["nginx", "-c", "/etc/nginx/nginx.conf"]
CMD ["-g", "daemon off;"]
+32
View File
@@ -0,0 +1,32 @@
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 3000;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location ~ /\. {
deny all;
}
}
}