version: '3.8'

services:
  ss-crawler:
    build:
      context: .
      dockerfile: Dockerfile
    image: ss-crawler:latest
    container_name: ss-crawler
    volumes:
      # Mount configs
      - ./configs:/app/configs:ro
      # Mount data directory for exports
      - ./data:/app/data
      # Mount logs
      - ./logs:/app/logs
    environment:
      - PYTHONUNBUFFERED=1
    # Override command when running
    # Example: docker-compose run ss-crawler python main.py crawl configs/gardenkindtees-com.yaml --safe
    command: python main.py --help

  api:
    build:
      context: .
      dockerfile: Dockerfile
    image: ss-crawler:latest
    container_name: ss-crawler-api
    ports:
      - "8001:8001"
    volumes:
      # Mount configs (read-write for API to create configs)
      - ./configs:/app/configs
      # Mount data directory for exports
      - ./data:/app/data
      # Mount logs
      - ./logs:/app/logs
      # Mount API code
      - ./api:/app/api
      # Mount wordpress-plugin directory to serve plugin ZIP
      - ./wordpress-plugin:/app/wordpress-plugin
    environment:
      - PYTHONUNBUFFERED=1
    command: python -m uvicorn api.main:app --host 0.0.0.0 --port 8001
    restart: unless-stopped

  worker:
    build:
      context: .
      dockerfile: Dockerfile
    image: ss-crawler:latest
    container_name: ss-crawler-worker
    volumes:
      # Mount configs (read-write for worker to merge configs)
      - ./configs:/app/configs
      # Mount data directory for exports
      - ./data:/app/data
      # Mount logs
      - ./logs:/app/logs
      # Mount scripts
      - ./scripts:/app/scripts
    environment:
      - PYTHONUNBUFFERED=1
    command: python scripts/crawl_worker.py
    restart: unless-stopped
    depends_on:
      - api

