name: skg-agent-cut

services:
  postgres:
    image: postgres:16-alpine
    container_name: skg-agent-postgres
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-skg_marketing}
      POSTGRES_USER: ${POSTGRES_USER:-skg_marketing}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    restart: unless-stopped
    networks:
      - skg-agent-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-skg_marketing} -d ${POSTGRES_DB:-skg_marketing}"]
      interval: 10s
      timeout: 5s
      retries: 10

  api:
    build:
      context: .
      dockerfile: Dockerfile.api
    container_name: skg-agent-api
    env_file:
      - ./deploy/.env.production
    environment:
      JOBS_DIR: /data/jobs
      AGENT_RUNS_DIR: /data/agent_runs
      ASSET_LIBRARY_DIR: /data/asset_library
      PROMPT_LIBRARY_DIR: /data/prompt_library
      DATABASE_URL: ${DATABASE_URL:?DATABASE_URL is required}
      CORS_ORIGINS: http://2.24.28.41:4290,http://localhost:4290
    volumes:
      - ./data/jobs:/data/jobs
      - ./data/agent_runs:/data/agent_runs
      - ./data/asset_library:/data/asset_library
      - ./data/prompt_library:/data/prompt_library
      - ./data/_trash:/data/_trash
      - ./secrets/tiktok_cookies.txt:/run/secrets/tiktok_cookies.txt
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      skg-agent-internal:
        aliases:
          - skg-marketing-api

  web:
    build:
      context: .
      dockerfile: Dockerfile.web
      args:
        NEXT_PUBLIC_API_BASE: /api
    container_name: skg-agent-web
    depends_on:
      - api
    ports:
      - "0.0.0.0:4290:80"
    restart: unless-stopped
    networks:
      - skg-agent-internal

networks:
  skg-agent-internal:
    name: skg-agent-internal
