services:
  platform-agent:
    build:
      context: ./external/platform-agent
      target: development
      additional_contexts:
        agent_api: ./external/platform-agent_api
    env_file: .env
    environment:
      PYTHONUNBUFFERED: "1"
    volumes:
      - ./external/platform-agent/src:/app/src
      - ./external/platform-agent_api:/agent_api
      - workspace:/workspace
    command: >
      sh -lc "
        mkdir -p /workspace &&
        chown -R agent:agent /workspace &&
        exec /app/.venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 8000
      "
    ports:
      - "8000:8000"
    restart: unless-stopped

  matrix-bot:
    build: .
    env_file: .env
    environment:
      AGENT_BASE_URL: http://platform-agent:8000
      SURFACES_WORKSPACE_DIR: /workspace
    depends_on:
      - platform-agent
    volumes:
      - workspace:/workspace
      - ./config:/app/config:ro
    restart: unless-stopped

volumes:
  workspace:
