version: "3.9"

services:
  survey-api:
    image: ghcr.io/avian-observatory/bird-survey-api:1.14.2
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      PORT: "8080"
      DATABASE_URL: postgres://survey:${POSTGRES_PASSWORD}@postgres:5432/bird_survey
      REDIS_URL: redis://redis:6379/0
      OBSERVATION_UPLOAD_BUCKET: citizen-bird-survey-uploads
      TAXONOMY_VERSION: ebird-2025
      MIN_LOCATION_ACCURACY_METERS: "75"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    volumes:
      - ./config/species-checklists:/app/config/species-checklists:ro

  worker:
    image: ghcr.io/avian-observatory/bird-survey-worker:1.14.2
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://survey:${POSTGRES_PASSWORD}@postgres:5432/bird_survey
      REDIS_URL: redis://redis:6379/0
      MEDIA_QUEUE: observation-media
      VALIDATION_QUEUE: sighting-validation
    depends_on:
      - survey-api
      - redis

  postgres:
    image: postgis/postgis:16-3.4
    restart: unless-stopped
    environment:
      POSTGRES_DB: bird_survey
      POSTGRES_USER: survey
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres-data:/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: 5

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

  dashboard:
    image: ghcr.io/avian-observatory/bird-survey-dashboard:1.14.2
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      API_BASE_URL: http://survey-api:8080
      MAP_DEFAULT_CENTER: "44.6488,-63.5752"
      MAP_DEFAULT_ZOOM: "8"
    depends_on:
      - survey-api

volumes:
  postgres-data:
  redis-data: