name: bird-survey-platform

services:
  api:
    image: ghcr.io/citizen-birds/survey-api:1.12.3
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      DATABASE_URL: postgres://survey:${POSTGRES_PASSWORD}@db:5432/bird_survey
      REDIS_URL: redis://redis:6379/0
      MEDIA_BUCKET: bird-survey-media
      ENABLE_AUDIO_UPLOADS: "true"
      MAX_OBSERVATION_PHOTOS: "6"
      DEFAULT_TIMEZONE: America/Toronto
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    healthcheck:
      test: ["CMD", "curl", "-fsS", "http://localhost:8080/healthz"]
      interval: 30s
      timeout: 5s
      retries: 3

  worker:
    image: ghcr.io/citizen-birds/survey-worker:1.12.3
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://survey:${POSTGRES_PASSWORD}@db:5432/bird_survey
      REDIS_URL: redis://redis:6379/0
      TASK_QUEUES: observations,checklists,media,alerts
      SPECIES_TAXONOMY: clements-2025
      LOW_CONFIDENCE_REVIEW_THRESHOLD: "0.72"
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started

  scheduler:
    image: ghcr.io/citizen-birds/survey-scheduler:1.12.3
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://survey:${POSTGRES_PASSWORD}@db:5432/bird_survey
      REDIS_URL: redis://redis:6379/0
      DAILY_EXPORT_CRON: "15 2 * * *"
      RARE_BIRD_ALERT_CRON: "*/20 * * * *"
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started

  db:
    image: postgis/postgis:16-3.4
    restart: unless-stopped
    environment:
      POSTGRES_DB: bird_survey
      POSTGRES_USER: survey
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - survey-db:/var/lib/postgresql/data
      - ./db/init:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U survey -d bird_survey"]
      interval: 10s
      timeout: 5s
      retries: 6

  redis:
    image: redis:7.2-alpine
    restart: unless-stopped
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - survey-redis:/data

volumes:
  survey-db:
  survey-redis: