# docker-compose.yml — runs control-plane, agent-micro, agent-gateway
# inside alpine:latest containers. The agents need the host docker socket
# bind-mounted so they can manage service containers.
#
# Use on a single host (e.g. 186) for dev. In production, the agents
# live on their own VMs and the control plane lives on 186.

services:
  control-plane:
    image: alpine:latest
    container_name: sdp-control-plane
    restart: unless-stopped
    command: ["/SDP/bin/control-plane", "-addr", ":3452", "-data", "/SDP/data"]
    volumes:
      - ./bin/control-plane:/SDP/bin/control-plane:ro
      - sdp-data:/SDP/data
    ports:
      - "3452:3452"

  agent-micro:
    image: alpine:latest
    container_name: sdp-agent-micro
    restart: unless-stopped
    # agent connects to the control plane by container name on the compose
    # network. Override SDP_CP_URL when running outside compose.
    command:
      - /SDP/bin/agent-micro
      - -node
      - micro
      - -cp
      - ws://control-plane:3452/ws/agent
    volumes:
      - ./bin/agent-micro:/SDP/bin/agent-micro:ro
      - /var/run/docker.sock:/var/run/docker.sock
      # Repos live on the host. Adjust to the actual paths.
      - ~/AppGolang:/AppGolang:ro
    environment:
      - DOCKER_HOST=unix:///var/run/docker.sock
    depends_on:
      - control-plane

  agent-gateway:
    image: alpine:latest
    container_name: sdp-agent-gateway
    restart: unless-stopped
    command:
      - /SDP/bin/agent-gateway
      - -node
      - gateway
      - -cp
      - ws://control-plane:3452/ws/agent
    volumes:
      - ./bin/agent-gateway:/SDP/bin/agent-gateway:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ~/SDP/repos:/SDP-repos:ro
    environment:
      - DOCKER_HOST=unix:///var/run/docker.sock
    depends_on:
      - control-plane

volumes:
  sdp-data:
