version: '3.8'

services:
  postgres:
    image: postgres:16
    container_name: pg_isep_persist
    environment:
      POSTGRES_USER: etudiant
      POSTGRES_PASSWORD: Isep2026!
      POSTGRES_DB: gestion_ecole
    volumes:
      - pg_data:/var/lib/postgresql/data
    ports:
      - "127.0.0.1:5432:5432"
    networks:
      - isep_net
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U etudiant"]
      interval: 10s
      timeout: 5s
      retries: 5

  pgadmin:
    image: dpage/pgadmin4
    container_name: pgadmin_isep_persist
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@isep.sn
      PGADMIN_DEFAULT_PASSWORD: Admin2026!
    ports:
      - "5050:80"
    networks:
      - isep_net
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

volumes:
  pg_data:
    driver: local

networks:
  isep_net:
    driver: bridge
