diff --git a/VContainers/VApp/Containerfile b/VContainers/VApp/Containerfile new file mode 100644 index 00000000..e12f8e64 --- /dev/null +++ b/VContainers/VApp/Containerfile @@ -0,0 +1,18 @@ +#FROM docker.io/nginx:stable-alpine +FROM docker.io/node:lts-alpine AS builder +## Bundle APP files +WORKDIR /app +COPY VApp ./ +RUN npm install +RUN npm run build + +FROM docker.io/nginx:stable-alpine +RUN rm /etc/nginx/conf.d/default.conf +COPY ./VContainers/VApp/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=builder /app/dist /usr/share/nginx/html + + +EXPOSE 80 + +# CMD ["npm","run","dev"] +#CMD ["sleep", "1000"] \ No newline at end of file diff --git a/VContainers/VApp/nginx.conf b/VContainers/VApp/nginx.conf new file mode 100644 index 00000000..a15e95ba --- /dev/null +++ b/VContainers/VApp/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + root /usr/share/nginx/html; # Chemin où les fichiers statiques sont copiés + + index index.html index.htm; # Fichier par défaut à servir + + location / { + try_files $uri $uri/ /index.html; # Pour les applications SPA (Single Page Applications) + # cela redirige toutes les requêtes non trouvées vers index.html + } + + # Cache Control pour les fichiers statiques (optionnel mais bonne pratique) + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires 30d; + add_header Cache-Control "public, no-transform"; + } + + # Gzip compression (optionnel, améliore la performance) + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; +} \ No newline at end of file