feat(frontend): simplication de la conf nginx + ajout du stage pour le runner dans le dockerfile
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
@@ -13,3 +17,31 @@ 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;"]
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user