services:
  chassepeche-api:
    image: "${CI_REGISTRY_IMAGE}:latest"
    restart: unless-stopped
    depends_on:
      - pgsql
    ports:
      - "8002:80"
    environment:
      APP_ENV: "local"
      APP_KEY: "${APP_KEY}"
      APP_URL: "${APP_URL}"
      APP_DEBUG: "true"
      FILESYSTEM_DISK: "public"
      DB_CONNECTION: "pgsql"
      DB_HOST: "pgsql"
      DB_PORT: 5432
      DB_DATABASE: "${DB_DATABASE}"
      DB_USERNAME: "${DB_USERNAME}"
      DB_PASSWORD: "${DB_PASSWORD}"
    volumes:
      - storage-data:/var/www/html/storage/app
      - storage-public-data:/var/www/html/storage/app/public

  pgsql:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: "${DB_DATABASE}"
      POSTGRES_USER: "${DB_USERNAME}"
      POSTGRES_PASSWORD: "${DB_PASSWORD}"
    volumes:
      - pgsql-data:/var/lib/postgresql
    ports:
      - "5428:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}" ]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  adminer:
    image: adminer:latest
    restart: unless-stopped
    ports:
      - "8083:8080" # Accès via http://localhost:8080
    depends_on:
      - pgsql

volumes:
  pgsql-data:
    external: true
    name: todo_pgsql_data
  storage-data:
  storage-public-data:
    name: todo_storage_public_data
