Add Docker and Nginx configuration for production deployment
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*.log
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
# ÉTAPE 1 : Build de l'application
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copie des fichiers de dépendances et installation
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copie du reste du code source
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Compilation de l'application (génère le dossier /dist)
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ÉTAPE 2 : Serveur Nginx de production
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copie de la configuration Nginx pour le React Router
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Copie des fichiers compilés depuis l'étape 1
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Exposition du port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Démarrage de Nginx
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
board-score:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: board-score-app
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
# Optionnel: si vous avez des logos dans un dossier externe sur votre machine hôte
|
||||||
|
# volumes:
|
||||||
|
# - ./games-assets:/usr/share/nginx/html/games-assets
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Important pour les Single Page Applications (React Router)
|
||||||
|
# Si le fichier n'existe pas, on redirige vers index.html
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mise en cache agressive pour les assets statiques
|
||||||
|
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg|webp)$ {
|
||||||
|
expires 6M;
|
||||||
|
access_log off;
|
||||||
|
add_header Cache-Control "public, max-age=15552000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ne pas mettre en cache le service worker pour que la PWA se mette à jour
|
||||||
|
location = /sw.js {
|
||||||
|
expires -1;
|
||||||
|
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user