# AI Task Manager: run the published image with Docker Compose.
#
#   docker compose up -d          # then open http://localhost:3000
#
# Or let the installer do it: curl -fsSL https://aitaskmanager.orangeball.dev/install.sh | sh
# Generated from https://github.com/orangeballdev/ai-task-manager/blob/main/docker-compose.yml by scripts/site/build.tsx.
# Env: AI_TASK_MANAGER_PORT (default 3000), AI_TASK_MANAGER_TAG (default latest).
services:
  migrate:
    image: ghcr.io/orangeballdev/ai-task-manager:${AI_TASK_MANAGER_TAG:-latest}
    command: npx prisma migrate deploy
    environment:
      DATABASE_URL: file:/data/dev.db
    volumes:
      - db_data:/data
    restart: "no"

  app:
    image: ghcr.io/orangeballdev/ai-task-manager:${AI_TASK_MANAGER_TAG:-latest}
    command: node .next/standalone/server.js
    environment:
      DATABASE_URL: file:/data/dev.db
      WORKSPACES_PATH: /workspaces
      # Pasted/attached images: must be on a volume the app (which stores uploads)
      # and the worker (which copies them into task workspaces) both mount.
      ATTACHMENTS_PATH: /data/attachments
      NODE_ENV: production
      HOSTNAME: 0.0.0.0
      PORT: "3000"
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
      AWS_REGION: ${AWS_REGION:-}
    ports:
      # AI_TASK_MANAGER_PORT picks another host port (the installer passes it through).
      - "${AI_TASK_MANAGER_PORT:-3000}:3000"
    volumes:
      - workspaces:/workspaces
      - db_data:/data
      - claude_home:/home/appuser/.claude
    depends_on:
      migrate:
        condition: service_completed_successfully
    restart: unless-stopped

  worker:
    image: ghcr.io/orangeballdev/ai-task-manager:${AI_TASK_MANAGER_TAG:-latest}
    command: npx tsx src/worker/index.ts
    # Reap orphaned git/esbuild children; npm as PID 1 leaves them as zombies.
    init: true
    environment:
      DATABASE_URL: file:/data/dev.db
      WORKSPACES_PATH: /workspaces
      # Pasted/attached images: must be on a volume the app (which stores uploads)
      # and the worker (which copies them into task workspaces) both mount.
      ATTACHMENTS_PATH: /data/attachments
      NODE_ENV: production
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
      AWS_REGION: ${AWS_REGION:-}

    volumes:
      - workspaces:/workspaces
      - db_data:/data
      - claude_home:/home/appuser/.claude
      # Mount SSH keys so the worker can clone private repos
      - ~/.ssh:/home/appuser/.ssh:ro
    depends_on:
      migrate:
        condition: service_completed_successfully
    restart: unless-stopped

  integrations:
    image: ghcr.io/orangeballdev/ai-task-manager:${AI_TASK_MANAGER_TAG:-latest}
    command: npx tsx src/integrations/index.ts
    environment:
      DATABASE_URL: file:/data/dev.db
      NODE_ENV: production
    volumes:
      - db_data:/data
    depends_on:
      migrate:
        condition: service_completed_successfully
    restart: unless-stopped

volumes:
  workspaces:
  db_data:
  claude_home:
