feat: Ajout monitoring Prometheus/Grafana et configuration déploiement serveur Linux
- 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
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
services:
|
||||
# Base de données PostgreSQL
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
container_name: dockezr_db_prod
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-user}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-dockezr}
|
||||
ports:
|
||||
- "${DB_PORT:-5432}:5432"
|
||||
volumes:
|
||||
- postgres_data_prod:/var/lib/postgresql/data
|
||||
networks:
|
||||
- dockezr_network_prod
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-user} -d ${POSTGRES_DB:-dockezr}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# Backend FastAPI
|
||||
backend:
|
||||
image: ${DOCKERHUB_USERNAME}/${DOCKERHUB_REPO}-backend:${VERSION:-latest}
|
||||
container_name: dockezr_backend_prod
|
||||
restart: always
|
||||
environment:
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@db:5432/${POSTGRES_DB:-dockezr}
|
||||
ports:
|
||||
- "${BACKEND_PORT:-8001}:8000"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- dockezr_network_prod
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Frontend Next.js
|
||||
frontend:
|
||||
image: ${DOCKERHUB_USERNAME}/${DOCKERHUB_REPO}-frontend:${VERSION:-latest}
|
||||
container_name: dockezr_frontend_prod
|
||||
restart: always
|
||||
environment:
|
||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8001}
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-3000}:3000"
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- dockezr_network_prod
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# Prometheus - Monitoring et métriques
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: dockezr_prometheus_prod
|
||||
restart: always
|
||||
ports:
|
||||
- "${PROMETHEUS_PORT:-9090}:9090"
|
||||
volumes:
|
||||
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data_prod:/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_prod
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
# Grafana - Tableaux de bord et visualisation
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: dockezr_grafana_prod
|
||||
restart: always
|
||||
ports:
|
||||
- "${GRAFANA_PORT:-3001}:3000"
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_USER=${GRAFANA_USER:-admin}
|
||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin123}
|
||||
- GF_USERS_ALLOW_SIGN_UP=false
|
||||
volumes:
|
||||
- grafana_data_prod:/var/lib/grafana
|
||||
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
||||
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards
|
||||
networks:
|
||||
- dockezr_network_prod
|
||||
depends_on:
|
||||
- prometheus
|
||||
|
||||
networks:
|
||||
dockezr_network_prod:
|
||||
driver: bridge
|
||||
name: dockezr_network_prod
|
||||
|
||||
volumes:
|
||||
postgres_data_prod:
|
||||
name: dockezr_postgres_data_prod
|
||||
prometheus_data_prod:
|
||||
name: dockezr_prometheus_data_prod
|
||||
grafana_data_prod:
|
||||
name: dockezr_grafana_data_prod
|
||||
Reference in New Issue
Block a user