version: "3.9"

services:
  api:
    image: ghcr.io/acme/podcast-hosting-api:1.14.2
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      LOG_LEVEL: info
      DATABASE_URL: postgres://podcast:${POSTGRES_PASSWORD}@postgres:5432/podcasts
      REDIS_URL: redis://redis:6379/0
      STORAGE_DRIVER: s3
      S3_BUCKET: podcast-media
      S3_REGION: us-east-1
      CDN_BASE_URL: https://cdn.example.com
      JWT_ISSUER: podcast-platform
      RSS_FEED_CACHE_TTL_SECONDS: "300"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  worker:
    image: ghcr.io/acme/podcast-hosting-worker:1.14.2
    restart: unless-stopped
    command: ["queue:work", "--queues=uploads,feeds,analytics"]
    environment:
      DATABASE_URL: postgres://podcast:${POSTGRES_PASSWORD}@postgres:5432/podcasts
      REDIS_URL: redis://redis:6379/0
      STORAGE_DRIVER: s3
      S3_BUCKET: podcast-media
      S3_REGION: us-east-1
    depends_on:
      - api
      - redis

  transcoder:
    image: ghcr.io/acme/podcast-transcoder:0.9.8
    restart: unless-stopped
    command: ["transcode:listen"]
    environment:
      REDIS_URL: redis://redis:6379/0
      INPUT_BUCKET: podcast-uploads
      OUTPUT_BUCKET: podcast-media
      DEFAULT_AUDIO_BITRATE: 128k
      NORMALIZE_LOUDNESS: "true"
      TARGET_LUFS: "-16"
    volumes:
      - transcoder-cache:/tmp/transcoder

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

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

volumes:
  postgres-data:
  redis-data:
  transcoder-cache: