From 50557bff925ee53b4bedadd8c7de11b28aab09d5 Mon Sep 17 00:00:00 2001 From: "Mamadou Khoussa [028918 DSI/DAC/DIF/DS]" Date: Tue, 28 Oct 2025 11:24:17 +0000 Subject: [PATCH] fix build file --- Dockerfile | 31 +++++++++++++++++++++++++++++++ nginx.conf | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..26cb865 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Stage 1: Build de l'application Angular +FROM node:20-alpine AS build + +WORKDIR /app + +# Copier les fichiers de dépendances +COPY package*.json ./ + +# Installer les dépendances +RUN npm ci + +# Copier le reste des fichiers du projet +COPY . . + +# Builder l'application en mode production +RUN npm run build + +# Stage 2: Servir l'application avec Nginx +FROM nginx:alpine + +# Copier les fichiers buildés depuis le stage précédent +COPY --from=build /app/dist/dcb-bo-admin/browser /usr/share/nginx/html + +# Copier la configuration Nginx personnalisée (optionnel) +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Exposer le port 80 +EXPOSE 80 + +# Démarrer Nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7efc4c1 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Compression gzip + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript; + + # Cache des assets statiques + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Redirection pour le routing Angular + location / { + try_files $uri $uri/ /index.html; + } + + # Sécurité - cacher la version Nginx + server_tokens off; + + # Headers de sécurité + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; +}