services:
  # ── API ──
  reader-api:
    build:
      context: .
      dockerfile: Dockerfile.api
    container_name: reader-api
    restart: unless-stopped
    environment:
      - DATABASE_URL=postgresql+asyncpg://brain:brain@brain-db:5432/brain
      - REDIS_URL=redis://brain-redis:6379/0
      - CRAWLER_URL=http://brain-crawler:3100
      - PORT=8300
      - DEBUG=${DEBUG:-0}
      - TZ=${TZ:-America/Chicago}
    networks:
      - default
      - pangolin
      - brain

  # ── Worker (feed fetcher + scheduler) ──
  reader-worker:
    build:
      context: .
      dockerfile: Dockerfile.worker
    container_name: reader-worker
    restart: unless-stopped
    environment:
      - DATABASE_URL=postgresql+asyncpg://brain:brain@brain-db:5432/brain
      - REDIS_URL=redis://brain-redis:6379/0
      - CRAWLER_URL=http://brain-crawler:3100
      - FEED_FETCH_INTERVAL=600
      - TZ=${TZ:-America/Chicago}
    networks:
      - default
      - brain

networks:
  pangolin:
    external: true
  brain:
    name: brain_default
    external: true
