feat: ajout Docker Compose et documentation outils
- Dockerfile backend (Python 3.11 + Poetry + Playwright/Chromium) - Dockerfile frontend (Node 20 + Vite build + Nginx) - docker-compose.yml avec services et volumes persistants - Proxy Nginx pour API (/api -> backend:8008) - Healthchecks sur les deux services - Configuration Docker (.env.docker, .dockerignore) - Documentation déploiement Docker dans README - Fichier docs/tools_used.md avec liste des technologies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
40
docker/frontend/Dockerfile
Normal file
40
docker/frontend/Dockerfile
Normal file
@@ -0,0 +1,40 @@
|
||||
# Dockerfile Frontend - Build Vite + Nginx
|
||||
# Stage 1: Build
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copier les fichiers de dépendances
|
||||
COPY frontend/package*.json ./
|
||||
|
||||
# Installer les dépendances
|
||||
RUN npm ci
|
||||
|
||||
# Copier le code source
|
||||
COPY frontend/ ./
|
||||
|
||||
# Argument pour l'URL de l'API (défaut: docker network)
|
||||
ARG VITE_API_URL=http://backend:8008
|
||||
|
||||
# Build de production
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Nginx
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copier la config Nginx personnalisée
|
||||
COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copier les fichiers buildés
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Copier le script d'entrypoint pour injecter les variables d'environnement
|
||||
COPY docker/frontend/entrypoint.sh /docker-entrypoint.d/40-env-config.sh
|
||||
RUN chmod +x /docker-entrypoint.d/40-env-config.sh
|
||||
|
||||
# Exposer le port
|
||||
EXPOSE 80
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD wget -q --spider http://localhost/ || exit 1
|
||||
13
docker/frontend/entrypoint.sh
Normal file
13
docker/frontend/entrypoint.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Entrypoint pour injecter la configuration API au runtime
|
||||
|
||||
# Si VITE_API_URL est défini, on l'injecte dans la config frontend
|
||||
if [ -n "$VITE_API_URL" ]; then
|
||||
# Remplacer l'URL de l'API dans config_frontend.json si présent
|
||||
CONFIG_FILE="/usr/share/nginx/html/config_frontend.json"
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
# Utiliser sed pour remplacer l'URL de l'API
|
||||
sed -i "s|http://localhost:8008|${VITE_API_URL}|g" "$CONFIG_FILE"
|
||||
echo "Config API URL updated to: $VITE_API_URL"
|
||||
fi
|
||||
fi
|
||||
47
docker/frontend/nginx.conf
Normal file
47
docker/frontend/nginx.conf
Normal file
@@ -0,0 +1,47 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
resolver 127.0.0.11 ipv6=off valid=10s;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml;
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# SPA fallback - toutes les routes vers index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Proxy vers le backend API
|
||||
location /api/ {
|
||||
set $backend_upstream http://backend:8008;
|
||||
rewrite ^/api/(.*)$ /$1 break;
|
||||
proxy_pass $backend_upstream;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# Health check endpoint
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user