name: birdwatch-survey

services:
  api:
    image: ghcr.io/fieldlab/birdwatch-api:1.8.2
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      DATABASE_URL: postgres://birdwatch:${POSTGRES_PASSWORD}@db:5432/birdwatch
      REDIS_URL: redis://redis:6379/0
      MEDIA_BUCKET: birdwatch-observations
      GPS_PRECISION_METERS: "25"
      MAX_UPLOAD_MB: "20"
      ENABLE_SPECIES_SUGGESTIONS: "true"
      REVIEW_QUEUE_THRESHOLD: "0.72"
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started

  worker:
    image: ghcr.io/fieldlab/birdwatch-worker:1.8.2
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://birdwatch:${POSTGRES_PASSWORD}@db:5432/birdwatch
      REDIS_URL: redis://redis:6379/0
      EBIRD_TAXONOMY_VERSION: "2025"
      NIGHTLY_EXPORT_CRON: "15 3 * * *"
    depends_on:
      - api
      - redis

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

  redis:
    image: redis:7.2-alpine
    restart: unless-stopped
    volumes:
      - birdwatch-cache:/data

  scheduler:
    image: ghcr.io/fieldlab/birdwatch-scheduler:1.8.2
    restart: unless-stopped
    environment:
      API_BASE_URL: http://api:8080
      SURVEY_TIMEZONE: America/Toronto
      REMINDER_WINDOW_DAYS: "2"
      SEASON_START: "2026-04-15"
      SEASON_END: "2026-07-31"
    depends_on:
      - api

volumes:
  birdwatch-db:
  birdwatch-cache: