Files
clawmates/deploy/compose/docker-compose.yml
T
Omar SobhandClaude Opus 4.8 148705769f
ci / gates (push) Has been cancelled
ci / rust (push) Has been cancelled
ci / sandbox-k8s (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / e2e (push) Has been cancelled
Reaping: sandbox orphan reaper + DB expiry/retention sweeper + volume-init retry
Closes the cleanup gaps found in review (latent today; bites under load/crashes).

Sandbox containers (cm-sandbox / cm-runtime):
- label every sandbox `clawmates.sandbox={agent|browser}` at create
- SandboxDriver::list_managed(kind) (Docker label filter + K8s label selector)
- SandboxManager::reconcile_orphans(ttl) + spawn_reaper: removes engine
  containers no live handle owns (ZERO = all)
- boot reconciliation (every pre-existing sandbox is an orphan from a dead
  process) + periodic reaper (5m interval / 10m TTL)
- SIGTERM graceful drain: serve().with_graceful_shutdown → shutdown() both
  managers so a redeploy can't leak; destroy errors now logged not swallowed

DB expiry/retention (cm-db cleanup.rs + cm-api cleanup_sweeper, hourly):
- expire auth_sessions + oauth_states past expires_at (security)
- prune sent outbox(7d), run_events(14d), routine_runs(30d), terminal
  topology_runs(90d), consumed execution_grants(7d)

Compose: volume-init restart "no" → on-failure:5 (retry instead of wedging boot).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-19 04:55:27 -07:00

143 lines
4.5 KiB
YAML

# Air-gapped single-node topology. The network segmentation IS the security
# model (spec §15):
# edge — host-published entry points only (frontend, server API)
# core — internal: server <-> postgres
# sandbox_net — internal, NO egress: agent sandboxes (joined in P2)
# secrets_net — internal: secret broker + server only (joined in P2)
# Images are preloaded from the signed offline bundle; nothing pulls at
# install time.
name: clawmates
networks:
edge: {}
core:
internal: true
sandbox_net:
internal: true
secrets_net:
internal: true
# Server <-> socket proxy only; the raw Docker socket never reaches the
# server container.
engine_net:
internal: true
volumes:
pgdata: {}
# Unix socket + master key shared ONLY between server and broker —
# the unix-socket equivalent of the K8s sidecar topology.
broker_run: {}
broker_key: {}
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: clawmates
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
volumes:
- pgdata:/var/lib/postgresql/data
networks: [core]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d clawmates"]
interval: 5s
timeout: 3s
retries: 12
# Named volumes mount root-owned, but the broker runs as uid 10001 from
# a scratch image (no shell to chown itself). This one-shot prepares the
# socket + key volumes, then exits. `on-failure` so a transient chown error
# retries instead of wedging boot (broker/server depend on it completing).
volume-init:
image: busybox:1.36
command: ["sh", "-c", "chown -R 10001:10001 /run/clawmates /etc/clawmates-broker"]
user: "0:0"
volumes:
- broker_run:/run/clawmates
- broker_key:/etc/clawmates-broker
restart: on-failure:5
# The secret broker: separate process, separate image; credentials
# never leave it. Reachable only via the shared unix socket volume.
broker:
image: clawmates/broker:${CLAWMATES_VERSION:-latest}
build:
context: ../..
dockerfile: images/broker.Dockerfile
restart: unless-stopped
environment:
CLAWMATES_BROKER_SOCKET: /run/clawmates/broker.sock
CLAWMATES_BROKER_KEY_FILE: /etc/clawmates-broker/broker.key
CLAWMATES_DATABASE__URL: postgres://postgres:${POSTGRES_PASSWORD:?set in .env}@postgres:5432/clawmates
volumes:
- broker_run:/run/clawmates
- broker_key:/etc/clawmates-broker
networks: [core]
depends_on:
postgres:
condition: service_healthy
volume-init:
condition: service_completed_successfully
# Allow-listed Docker API (§15 blast-radius cap): the server can
# create/exec/stop/remove sandbox containers and NOTHING else — no
# image builds, no networks, no secrets, no volumes. Proven by
# crates/cm-sandbox/tests/socket_proxy.rs against this exact allowlist.
socket-proxy:
image: tecnativa/docker-socket-proxy:0.3
restart: unless-stopped
environment:
CONTAINERS: 1
POST: 1
EXEC: 1
DELETE: 1
VERSION: 1
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks: [engine_net]
server:
image: clawmates/server:${CLAWMATES_VERSION:-latest}
build:
context: ../..
dockerfile: images/server.Dockerfile
restart: unless-stopped
# Operator knobs (bootstrap owner, LLM provider/key overrides, OTLP) come
# from .env — only the keys you actually set are injected, so unset
# options stay absent rather than overriding clawmates.toml with "".
env_file:
- path: .env
required: false
environment:
CLAWMATES_CONFIG: /etc/clawmates/clawmates.toml
CLAWMATES_DATABASE__URL: postgres://postgres:${POSTGRES_PASSWORD:?set in .env}@postgres:5432/clawmates
DOCKER_HOST: tcp://socket-proxy:2375
volumes:
- ./clawmates.toml:/etc/clawmates/clawmates.toml:ro
- broker_run:/run/clawmates
networks: [edge, core, engine_net]
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
frontend:
image: clawmates/frontend:${CLAWMATES_VERSION:-latest}
build:
context: ../..
dockerfile: images/frontend.Dockerfile
restart: unless-stopped
# AUTH_MODE + CLERK_* (when running Clerk) come from .env; see docs/clerk.md.
env_file:
- path: .env
required: false
environment:
API_ORIGIN: http://server:8080
networks: [edge]
ports:
- "3000:3000"
depends_on:
- server