# Dépendances pour le client : Postgres + Keycloak (et optionnellement le serveur API)
# Pour run-dev, le serveur tourne en local (mvn quarkus:dev) et le client pointe vers localhost:8080
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_DB: ${DB_NAME:-lions_user_manager}
      POSTGRES_USER: ${DB_USER:-lions}
      POSTGRES_PASSWORD: ${DB_PASSWORD:-lions}
    ports:
      - "${DB_PORT:-5432}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-lions} -d ${DB_NAME:-lions_user_manager}"]
      interval: 5s
      timeout: 5s
      retries: 5

  keycloak:
    image: quay.io/keycloak/keycloak:26.3.3
    command: start-dev
    environment:
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres:5432/${DB_NAME:-lions_user_manager}
      KC_DB_USERNAME: ${DB_USER:-lions}
      KC_DB_PASSWORD: ${DB_PASSWORD:-lions}
      KC_BOOTSTRAP_ADMIN_USERNAME: ${KC_ADMIN:-admin}
      KC_BOOTSTRAP_ADMIN_PASSWORD: ${KC_ADMIN_PASSWORD:-admin}
    ports:
      - "${KC_PORT:-8180}:8080"
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  postgres_data:
