name: aisupport-agent-runtime-local

services:
  volume-init:
    image: ${AGENT_SIDECAR_IMAGE:-aisupport-agent-sidecar:local}
    pull_policy: never
    user: "0:0"
    entrypoint: ["/bin/chown"]
    command:
      - "-R"
      - "1000:1000"
      - "/data/projects"
      - "/home/node/.codex"
    volumes:
      - agent-projects:/data/projects
      - agent-codex-home:/home/node/.codex
    restart: "no"

  agent-codex:
    image: ${AGENT_CODEX_IMAGE:-aisupport-agent-codex:local}
    build:
      context: ../..
      dockerfile: infra/images/agent-codex/Dockerfile
    depends_on:
      volume-init:
        condition: service_completed_successfully
    env_file:
      - path: ./.env
        required: true
    environment:
      CODEX_HOME: /home/node/.codex
    ports:
      - "127.0.0.1:${AGENT_CODEX_PORT:-4500}:4500"
      - "127.0.0.1:${AGENT_SIDECAR_PORT:-9091}:9091"
    volumes:
      - agent-projects:/data/projects
      - agent-codex-home:/home/node/.codex
      - ./config.toml:/home/node/.codex/config.toml:ro
      - ./model-catalog.local.json:/home/node/.codex/model-catalog.local.json:ro
    healthcheck:
      test: ["CMD", "curl", "--fail", "--silent", "http://127.0.0.1:4500/readyz"]
      interval: 5s
      timeout: 3s
      retries: 12
      start_period: 5s
    init: true
    restart: unless-stopped
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
      - seccomp:unconfined

  agent-sidecar:
    image: ${AGENT_SIDECAR_IMAGE:-aisupport-agent-sidecar:local}
    pull_policy: never
    depends_on:
      volume-init:
        condition: service_completed_successfully
      agent-codex:
        condition: service_healthy
    network_mode: "service:agent-codex"
    command:
      - "--config"
      - "/etc/agent-sidecar/config.yaml"
    volumes:
      - agent-projects:/data/projects
      - agent-codex-home:/home/node/.codex
      - ./config.local.yaml:/etc/agent-sidecar/config.yaml:ro
    init: true
    restart: unless-stopped
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true

volumes:
  agent-projects:
    name: aisupport-agent-projects
  agent-codex-home:
    name: aisupport-agent-codex-home
