name: podcast-hosting

services:
  api:
    image: ghcr.io/acme/podhost-api:${PODHOST_VERSION:-latest}
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      PUBLIC_BASE_URL: https://podcasts.example.com
      DATABASE_URL: postgres://podhost:${POSTGRES_PASSWORD}@postgres:5432/podhost
      REDIS_URL: redis://redis:6379/0
      STORAGE_ENDPOINT: http://minio:9000
      STORAGE_BUCKET: podcast-media
      STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY}
      STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY}
      RSS_CACHE_TTL_SECONDS: "300"
      TRANSCODE_QUEUE: podcast-transcodes
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
      minio:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-fsS", "http://localhost:8080/healthz"]
      interval: 30s
      timeout: 5s
      retries: 3

  worker:
    image: ghcr.io/acme/podhost-worker:${PODHOST_VERSION:-latest}
    restart: unless-stopped
    environment:
      APP_ENV: production
      DATABASE_URL: postgres://podhost:${POSTGRES_PASSWORD}@postgres:5432/podhost
      REDIS_URL: redis://redis:6379/0
      STORAGE_ENDPOINT: http://minio:9000
      STORAGE_BUCKET: podcast-media
      STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY}
      STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY}
      FFMPEG_PRESET: veryfast
      MAX_CONCURRENT_TRANSCODES: "4"
    depends_on:
      - api
      - redis
      - minio

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

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

  minio:
    image: minio/minio:RELEASE.2026-06-13T18-06-41Z
    restart: unless-stopped
    command: ["server", "/data", "--console-address", ":9001"]
    environment:
      MINIO_ROOT_USER: ${MINIO_ACCESS_KEY}
      MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY}
    volumes:
      - media-data:/data
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 20s
      timeout: 5s
      retries: 5

  rss-refresher:
    image: ghcr.io/acme/podhost-cli:${PODHOST_VERSION:-latest}
    restart: unless-stopped
    command: ["schedule", "rss:refresh", "--interval", "60s"]
    environment:
      DATABASE_URL: postgres://podhost:${POSTGRES_PASSWORD}@postgres:5432/podhost
      REDIS_URL: redis://redis:6379/0
    depends_on:
      - postgres
      - redis

volumes:
  postgres-data:
  redis-data:
  media-data: