services:
  db:
    image: postgres:17
    container_name: ynov-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin123
      POSTGRES_DB: ptitpas_db
    volumes:
      - ./migrations/01_init.sql:/docker-entrypoint-initdb.d/01_init.sql
      - postgres_data:/var/lib/postgresql/data
    networks:
      - ynov_network

  pgadmin:
    image: dpage/pgadmin4
    container_name: ynov-pgadmin
    restart: unless-stopped
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@ptits-pas.fr
      PGADMIN_DEFAULT_PASSWORD: admin123
    depends_on:
      - db
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.ynov-pgadmin.rule=Host(\"ynov-pgadmin.ptits-pas.fr\")"
      - "traefik.http.routers.ynov-pgadmin.entrypoints=websecure"
      - "traefik.http.routers.ynov-pgadmin.tls.certresolver=leresolver"
      - "traefik.http.services.ynov-pgadmin.loadbalancer.server.port=80"
    networks:
      - ynov_network
      - proxy_network

volumes:
  postgres_data:

networks:
  ynov_network:
    driver: bridge
  proxy_network:
    external: true
