Self-Hosting

Deploy Syntropic137 on your own infrastructure, from bare metal to Kubernetes

Deployment Architecture

Syntropic137 runs as a set of Docker services connected through a shared network:

Quick Start with Docker Compose

npx @syntropic137/setup init

The setup wizard handles everything: Docker validation, secret generation, API key configuration, image pulls, and starting the stack. See Getting Started for the full walkthrough.

The dashboard will be available at http://localhost:8137.

Services

Only the gateway is published on the host, at 127.0.0.1:8137 by default. The ports below are internal to the stack's Docker network and are not reachable from your machine.

ServiceInternal portDescription
gateway80nginx reverse proxy + dashboard frontend, published at 127.0.0.1:8137
api8000FastAPI backend: REST API, SSE (served under /api/v1/ through the gateway)
event-store50051gRPC event sourcing server
collector8080High-throughput event ingestion
timescaledb5432PostgreSQL + TimescaleDB for events and metrics
redis6379Caching, pub/sub, projection store
minio9000S3-compatible artifact storage

Workspace Isolation

Each agent execution runs in an isolated Docker workspace with a two-phase security model:

Setup Phase: Secrets are used to write git and gh credential files and are removed from the environment before the agent starts. The GitHub installation token stays in those files, readable by the agent, for the run (#725 tracks removing it).

Agent Phase: A claude phase runs with its Anthropic credential, ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN, as its only environment secret. A codex phase's credential is staged to ~/.codex/auth.json during provisioning, and its environment carries no Claude credential unless the phase sets allow_delegation: true, which stages both. A claude fallback_agent gets the Claude credential only for its own run. CODEX_AUTH_JSON and OPENAI_API_KEY are deployment variables, not something the agent sees. Git operations use cached credentials from the setup phase.

AppArmor hosts (Codex workspaces)

On a Linux host whose Docker daemon enforces AppArmor (Ubuntu 24.04 and most Debian/Ubuntu servers; docker info lists name=apparmor under Security Options), Codex workspaces run under the AppArmor profile agentic-codex-sandbox: Docker's default profile with its blanket deny mount, replaced by only the mounts the Codex sandbox (bubblewrap) performs. The workspace refuses to start until that profile is loaded, and the execution fails with the provision reason apparmor_profile_not_loaded naming the fix.

Load it once on the Docker host. It is persisted under /etc/apparmor.d, so it loads again at every boot:

# From a repository checkout (also run automatically by `just selfhost-up`):
just apparmor-setup

# Without a checkout, copy the profile shipped in the running API image:
docker exec syn137-api python -c \
  "from agentic_isolation import codex_sandbox_apparmor_profile_path as p; print(p().read_text(), end='')" \
  | sudo tee /etc/apparmor.d/agentic-codex-sandbox >/dev/null
sudo apparmor_parser -r /etc/apparmor.d/agentic-codex-sandbox

just selfhost-update re-runs this step on every update, before restarting services. On an npx install, re-run the two commands above after each update.

Workspace image after an update

.env.example carries the default workspace image digest, and a SYN_WORKSPACE_DOCKER_IMAGE value in .env overrides the built-in default. just selfhost-update replaces a value that is a default shipped by an older release with the new default and prints the change; any other value is treated as your own override and left alone. The API also logs a warning at startup when the configured image is an older shipped default. On an npx install, remove the variable from .env (or set it to the new digest) after updating. Hosts without AppArmor (macOS, Docker Desktop) need nothing; just apparmor-setup skips them. The profile adds no capabilities, never uses apparmor=unconfined, and leaves host sysctls alone.

Environment Variables

VariableDefaultDescription
APP_ENVIRONMENTdevelopmentEnvironment mode (development, beta, staging, production, selfhost, test, offline). The setup CLI sets selfhost
REDIS_URLredis://localhost:6379/0Redis connection URL. The self-host stack builds it from the Redis secret
SYN_STORAGE_MINIO_ENDPOINTMinIO S3 endpoint
SYN_STORAGE_MINIO_ACCESS_KEYMinIO access key
SYN_STORAGE_MINIO_SECRET_KEYMinIO secret key. The self-host stack reads it from the MinIO secret
SYN_GITHUB_APP_IDGitHub App ID for webhook triggers
SYN_GITHUB_APP_PRIVATE_KEY_FILEPath to the GitHub App private key (PEM). The self-host stack mounts secrets/github-app-private-key.pem and sets this
ANTHROPIC_API_KEYAPI key for claude phases. CLAUDE_CODE_OAUTH_TOKEN takes priority when both are set
CODEX_AUTH_JSONFull contents of a Codex ~/.codex/auth.json. Codex phases need it or OPENAI_API_KEY; it takes priority when both are set. Unused by claude phases
OPENAI_API_KEYOpenAI API key for codex phases, used when CODEX_AUTH_JSON is unset. Staged as Codex's API-key auth.json, never in the agent environment. Unused by claude phases

Scaling Options

Single Server (Self-Host)

One host runs up to SYN_EXECUTION_MAX_CONCURRENT executions at once (default 4); further starts queue. Each running execution holds a workspace container, by default limited to 2 CPU and 4 GB (SYN_WORKSPACE_CPU_LIMIT, SYN_WORKSPACE_MEMORY_LIMIT_MB), so size the host to the concurrency you set. In testing, 9 concurrent executions saturated a 16-core, 62 GB host.

Multi-Server

For 100โ€“1,000 concurrent agents, run multiple Syntropic137 instances behind a load balancer:

Kubernetes

For 1,000+ concurrent agents with auto-scaling:

  • Use Kata Containers runtime for workspace isolation
  • HPA with 70% CPU target, 3โ€“20 replicas
  • PersistentVolume for artifact storage

Authentication

Gateway credentials

The nginx gateway uses HTTP Basic Auth to protect external access. During npx @syntropic137/setup init, a strong random password (~256 bits of entropy) is generated automatically and stored in ~/.syntropic137/.env.

The setup wizard never prints the password to the terminal. Retrieve it from ~/.syntropic137/.env when needed:

# View password
grep SYN_API_PASSWORD ~/.syntropic137/.env | cut -d= -f2

# Copy to clipboard (macOS)
grep SYN_API_PASSWORD ~/.syntropic137/.env | cut -d= -f2 | pbcopy

# Set env vars for the syn CLI
export SYN_API_USER=admin
export SYN_API_PASSWORD=$(grep SYN_API_PASSWORD ~/.syntropic137/.env | cut -d= -f2)

npx @syntropic137/setup credentials rotate rotates the PostgreSQL, Redis and MinIO credentials, not this password. To change the gateway password, edit SYN_API_PASSWORD in ~/.syntropic137/.env and restart the stack:

npx @syntropic137/setup stop
npx @syntropic137/setup start

Port model

The gateway exposes two ports with different auth policies:

PortAuthUsed by
80 (published at SYN_GATEWAY_BIND, default 127.0.0.1:8137)None while bound to loopback; Basic Auth otherwise (the gateway refuses to start without SYN_API_PASSWORD)Docker health checks, internal service traffic, local dev (localhost:8137)
8081 (not published to the host)Basic Auth when SYN_API_PASSWORD is setCloudflare Tunnel, any external access

If you use Cloudflare Tunnel, your tunnel config must route to http://gateway:8081 (not localhost:8137). The setup wizard enforces this: npx @syntropic137/setup tunnel will exit with an error if SYN_API_PASSWORD is not set.

See the Tunnels guide for full setup instructions.

Pausing admission (maintenance mode)

Maintenance mode stops the deployment from admitting new executions while running executions carry on. Use it before a deploy that recreates the API container, so nothing new starts that the swap would kill. It is a property of the deployment, not of an execution; there is no paused execution.

# Read the current state
curl -u "admin:$SYN_API_PASSWORD" "$SYN_API_URL/api/v1/maintenance"

# Pause admission
curl -X PUT -u "admin:$SYN_API_PASSWORD" "$SYN_API_URL/api/v1/maintenance" \
  -H 'Content-Type: application/json' \
  -d '{"active": true, "reason": "deploying v0.34", "actor": "ops"}'

# Reopen admission
curl -X PUT -u "admin:$SYN_API_PASSWORD" "$SYN_API_URL/api/v1/maintenance" \
  -H 'Content-Type: application/json' -d '{"active": false}'

Request body (SetMaintenanceModeRequest): active (required), reason (up to 500 characters, echoed to every refused caller), actor (up to 200 characters). Response (MaintenanceModeResponse): active, reason, since (null while open), actor. There is no syn command for it; just pit-stop sets and clears it around a deploy.

While it is active:

  • A direct start (syn workflow run, POST /workflows/{id}/execute) is refused with 409 and the detail Execution admission is paused since <time>: <reason>. Running executions are unaffected; retry once maintenance mode clears.
  • A trigger that fires is recorded as paused rather than failed, and is offered again when admission reopens.
  • Starts already queued for an execution slot stay queued and start after the clear.

Behaviour and limits:

  • The state is durable: a restarted API container reads it and stays closed.
  • A PUT answers only once the state is stored. Pausing waits, for a bounded time, only for starts that already hold a slot and have not written their start event; it does not wait for queued starts. If that bound runs out, the answer is 503, the flag is not set, and admission is still open: retry the pause.
  • Clearing answers 503 if admission reopened but the work parked during the pause could not be woken. Admission is open; repeat the clear to re-announce.

Disk space on the workspace volume

Workspace directories are the largest thing the platform writes, and on a single host they share a filesystem with Postgres. Free space on that filesystem is measured and acted on before it runs out.

The floors are absolute GiB, not a percent of the disk. A run needs a number of bytes: 3.9% free of a 2 TB disk is 71 GiB, room for many runs, while 6% of a 100 GB disk is 6 GiB.

SettingDefaultEffect
SYN_DISK_PATHempty: the workspace directory (SYN_WORKSPACE_CONTAINER_DIR, default /workspaces)Directory whose filesystem is measured
SYN_DISK_RUN_RESERVE_GIB3Disk one running execution may still write (workspace clone, dependencies, caches, capture)
SYN_DISK_REFUSE_ADMISSION_BELOW_GIBempty: SYN_DISK_RUN_RESERVE_GIB x SYN_EXECUTION_MAX_CONCURRENT (12 GiB at the defaults)Below this many GiB free, new executions are refused
SYN_DISK_DEGRADED_BELOW_GIBempty: twice the admission floor (24 GiB at the defaults)Below this many GiB free, /health reports degraded (reason disk_space). Never below the admission floor
SYN_DISK_DEGRADED_BELOW_PERCENTempty (off)Optional: also degrade below this percent free
SYN_DISK_REFUSE_ADMISSION_BELOW_PERCENTempty (off)Optional: also refuse below this percent free. Crossing either floor refuses. Must not exceed the degraded percent

Why these defaults. A running execution holds one workspace at a time; its directory (clone, dependencies, caches, most phases starting cold) is estimated at 1 to 3 GB, so the reserve is the top of that range. The workspace image (about 4 GB) is pulled once per host and shared, so it is not part of the reserve. Admission stops while every run that can be in flight still has its reserve left to finish, so the floor grows with concurrency: 12 GiB at 4 concurrent, 60 GiB at 20, 300 GiB at 100. The degraded floor adds one more full set of runs: room to reclaim by hand, and to pull a new workspace image at the next upgrade.

Upgrading from a percent-only version. SYN_DISK_*_PERCENT values you already set keep working, as an extra floor on top of the GiB one. Unset them to judge on GiB alone, which is the new default.

/health carries a disk block (DiskSpaceHealth): path, state (ok, unmeasurable, low, critical), free_percent, free_bytes (both null when unmeasurable), degraded_below_bytes, refuse_admission_below_bytes, degraded_below_percent and refuse_admission_below_percent (null when unset), and detail, one line naming the free space, the floors and where the admission floor came from. low and unmeasurable degrade /health; only critical refuses work.

While critical, a new execution is refused with 507 before anything is written, with a detail naming the GiB free, the path, both floors and what to do. Recover by freeing space (finished workspace directories on the workspace volume, docker image prune) and retry. If the floor is wrong for your host, set SYN_DISK_REFUSE_ADMISSION_BELOW_GIB (or lower SYN_DISK_RUN_RESERVE_GIB when that is unset) in ~/.syntropic137/.env, then recreate the API container so it reads the new value: compose up -d, since a plain restart keeps the container's old environment.

Backup and Restore

From a repository checkout (the just selfhost-* stack), one command backs up the whole syn database: the event store, every projection, and the agent_events hypertable.

just selfhost-backup
just selfhost-restore /var/backups/syn/syn-20261008T030000Z.dump

selfhost-backup writes a compressed pg_dump custom-format archive into BACKUP_DIR, with a .manifest beside it (sha256 and every table's row count), and reports success only after reading every row back. The db-backup service also takes one on a schedule and prunes old ones:

SettingDefaultEffect
BACKUP_SCHEDULE0 3 * * *Five-field cron, in UTC
BACKUP_RETENTION_DAYS7Backups older than this are deleted after each successful backup. Only files the backup recorded creating (in BACKUP_DIR/.syn-db-backup.ledger) are ever deleted
BACKUP_DIR/var/backups/synHost directory for the archives

selfhost-restore stops api, collector, event-store and gateway, checks the archive against its manifest, restores it into a staging database with TimescaleDB's restore mode around pg_restore, verifies every table's row count, and only then swaps it in and starts the writers again. Execution admission comes back paused: the backup's queued and pending work could have run since it was taken, so nothing starts until you review it and resume with PUT /api/v1/maintenance ({"active": false}). The replaced database is kept as syn_pre_restore_<timestamp>, never dropped; drop it yourself once satisfied. It refuses to replace a database that already holds rows unless you pass --force, which first takes a fresh backup of it and stops if that backup fails.

Take a backup before an upgrade that bumps the event store or event-sourcing-platform, changes the PostgreSQL or TimescaleDB image, or runs a script that writes events. A normal application upgrade does not need one: the event store is append-only and projections are rebuilt from it.

The npx @syntropic137/setup installation does not include the backup service yet (#1791).

Tunnels (Optional)

For secure external access and GitHub Actions webhook delivery, set up a tunnel. Syntropic137 includes built-in Cloudflare Tunnel support via a Docker Compose profile.

See the Tunnels guide for setup instructions.

Secrets

Infrastructure secrets (database, Redis, MinIO) are stored as files in a secrets/ directory only the installing user can read, and mounted via Docker Compose's secrets mechanism, never baked into image layers. Application-level API keys (e.g. ANTHROPIC_API_KEY) are supplied via environment variables.

See Secrets Management for details on how secrets work and optional 1Password integration.

On this page