b8d075a2bd
- Ajout Prometheus et Grafana au docker-compose.yml - Métriques automatiques pour le backend FastAPI - Configuration de production avec docker-compose.prod.yml - Guide de déploiement manuel pour serveur Linux - Variables d'environnement sécurisées - Documentation complète de déploiement
142 lines
3.4 KiB
YAML
142 lines
3.4 KiB
YAML
services:
|
|
# Base de données PostgreSQL
|
|
db:
|
|
image: postgres:16-alpine
|
|
container_name: dockezr_db
|
|
restart: always
|
|
environment:
|
|
POSTGRES_USER: user
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: dockezr
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
networks:
|
|
- dockezr_network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U user -d dockezr"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Backend FastAPI
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: dockezr_backend
|
|
restart: always
|
|
environment:
|
|
DATABASE_URL: postgresql://user:password@db:5432/dockezr
|
|
ports:
|
|
- "8001:8000"
|
|
volumes:
|
|
- ./backend:/app
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
networks:
|
|
- dockezr_network
|
|
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
|
|
|
# Frontend Next.js
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: dockezr_frontend
|
|
restart: always
|
|
environment:
|
|
NEXT_PUBLIC_API_URL: http://localhost:8001
|
|
ports:
|
|
- "3000:3000"
|
|
volumes:
|
|
- ./frontend:/app
|
|
- /app/node_modules
|
|
- /app/.next
|
|
depends_on:
|
|
- backend
|
|
networks:
|
|
- dockezr_network
|
|
|
|
# Service de test
|
|
test:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile.test
|
|
container_name: dockezr_test
|
|
environment:
|
|
DATABASE_URL: postgresql://user:password@db:5432/dockezr
|
|
API_BASE_URL: http://backend:8000
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
backend:
|
|
condition: service_started
|
|
networks:
|
|
- dockezr_network
|
|
command: >
|
|
sh -c "echo '⏳ Attente du backend...' &&
|
|
sleep 15 &&
|
|
echo '🧪 Lancement des tests...' &&
|
|
pytest test_api.py -v --tb=short"
|
|
profiles:
|
|
- test
|
|
|
|
# Prometheus - Monitoring et métriques
|
|
prometheus:
|
|
image: prom/prometheus:latest
|
|
container_name: dockezr_prometheus
|
|
restart: always
|
|
ports:
|
|
- "9090:9090"
|
|
volumes:
|
|
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
- prometheus_data:/prometheus
|
|
command:
|
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
- '--storage.tsdb.path=/prometheus'
|
|
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
- '--web.console.templates=/etc/prometheus/consoles'
|
|
- '--storage.tsdb.retention.time=200h'
|
|
- '--web.enable-lifecycle'
|
|
networks:
|
|
- dockezr_network
|
|
depends_on:
|
|
- backend
|
|
|
|
# Grafana - Tableaux de bord et visualisation
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
container_name: dockezr_grafana
|
|
restart: always
|
|
ports:
|
|
- "3001:3000"
|
|
environment:
|
|
- GF_SECURITY_ADMIN_USER=admin
|
|
- GF_SECURITY_ADMIN_PASSWORD=admin123
|
|
- GF_USERS_ALLOW_SIGN_UP=false
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
|
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards
|
|
networks:
|
|
- dockezr_network
|
|
depends_on:
|
|
- prometheus
|
|
|
|
networks:
|
|
dockezr_network:
|
|
driver: bridge
|
|
name: dockezr_network
|
|
|
|
volumes:
|
|
postgres_data:
|
|
name: dockezr_postgres_data
|
|
prometheus_data:
|
|
name: dockezr_prometheus_data
|
|
grafana_data:
|
|
name: dockezr_grafana_data
|
|
|