version: '3.8'

services:
  # Base de données PostgreSQL locale (identique à la prod OVH)
  postgres-local:
    image: postgres:15-alpine
    container_name: web-sentinel-db-local
    restart: unless-stopped
    ports:
      - "5433:5432"  # Port 5433 pour ne pas conflitre avec un éventuel PostgreSQL local
    environment:
      - POSTGRES_USER=websentinel_user
      - POSTGRES_PASSWORD=WebSentinelDB2025!
      - POSTGRES_DB=websentinel_prod
    volumes:
      - postgres_local_data:/var/lib/postgresql/data
      - ./scripts/database:/docker-entrypoint-initdb.d  # Scripts d'init automatiques
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U websentinel_user -d websentinel_prod"]
      interval: 10s
      timeout: 5s
      retries: 5

  # PgAdmin pour gérer la base (optionnel, interface web)
  pgadmin-local:
    image: dpage/pgadmin4:latest
    container_name: web-sentinel-pgadmin-local
    restart: unless-stopped
    ports:
      - "5050:80"
    environment:
      - PGADMIN_DEFAULT_EMAIL=admin@websentinel.local
      - PGADMIN_DEFAULT_PASSWORD=admin
    volumes:
      - pgadmin_local_data:/var/lib/pgadmin
    depends_on:
      - postgres-local

volumes:
  postgres_local_data:
    driver: local
  pgadmin_local_data:
    driver: local

networks:
  default:
    name: web-sentinel-local
