Single VM with Compose

This page is for the operator who runs kōjō on one machine with hardware virtualization, with the sbx driver. What applies to every install (high availability, upgrades, secrets, sizing and the images) is on Deploy.

On one VM, Postgres runs in a container and kōjō runs on the host. The sbx sandbox driver drives the sbx CLI, which talks to the sandbox daemon of the host it runs on, so kōjō must run on the same host as sbx. The files are in deploy/compose and deploy/systemd.

The sbx driver needs sbx login and sbx policy init deny-all, run as the user kōjō runs as.

What the compose file runs

docker-compose.yml has one service.

Service Image What it does
postgres pgvector/pgvector:0.8.7-pg17, pinned by digest Postgres with pgvector. Database kojo, user kojo. Published on 127.0.0.1:5432 only.
Volume or mount Where Holds
postgres-data /var/lib/postgresql/data The database: sessions, the job queue, team memory, the audit log and the runtime config.
./initdb /docker-entrypoint-initdb.d, read-only 10-vector.sql, which creates the vector extension the first time Postgres initializes its data directory.

The service has a health check (pg_isready over TCP), restarts unless stopped, and runs with no-new-privileges. Never publish the database on another address: kōjō on the same host is its one client.

docker-compose.dev.yml in the same directory is a development overlay with kōjō in a container on the docker driver. It is for working on kōjō, not for running it; see Local stacks.

The environment file

.env (copied from .env.example) has two readers: Docker Compose, for the variables of docker-compose.yml, and the kōjō process, for the ${NAME} references of kojo.yaml and the model providers’ keys. Keep it to plain NAME=value lines without quotes, which both readers understand, and give it mode 0600.

Variable Read by Meaning
POSTGRES_PASSWORD compose, kojo.yaml Password of the database. kojo.yaml puts it into the database URL: letters and digits only.
POSTGRES_PORT compose Loopback port Postgres is published on. Default 5432. Change it in the database URL of kojo.yaml too.
KOJO_PUBLIC_URL kojo.yaml server.public_url.
KOJO_SESSION_SECRET kojo.yaml Signs the dashboard’s session cookie.
KOJO_ADMIN_TOKEN kojo.yaml The admin API token. At least 16 characters.
ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY, AZURE_OPENAI_API_KEY the model gateway Keys of the providers your tiers use. Vertex AI and Bedrock take Google Cloud and AWS credentials instead; see Models.
GITHUB_APP_ID, GITHUB_WEBHOOK_SECRET kojo.yaml From kojo setup github, once forges.github is uncommented.
SLACK_BOT_TOKEN, SLACK_APP_TOKEN kojo.yaml Once chat.slack is uncommented.

To load it into a shell: set -a; . ./.env; set +a.

kojo.yaml

The shipped kojo.yaml sets what kōjō needs to start:

  • server.listen: "127.0.0.1:8080": kōjō binds loopback, and a reverse proxy in front of it terminates TLS.
  • server.auth: the session secret and one admin API token. An oidc block is there, commented out.
  • database.url: the Postgres of the compose file on loopback.
  • models: the embedded gateway, the tiers fast and strong, and budgets of 10 USD per session and 200 USD per day as initial values.
  • sandbox.driver: sbx. There is no sandbox.proxy block: sbx enforces egress and injects credentials with its own proxy on the host, and kojo-proxy is not used with this driver.
  • defaults.merge_policy: draft_only.

The kojo.yaml reference lists every key. Tiers, budgets and policies in this file are initial values: after the first start they are managed in the dashboard and stored in Postgres.

Files kōjō reads

Secrets that are files do not go into .env. The GitHub App’s private key is named by forges.github.private_key_file; the shipped config expects /etc/kojo/secrets/github-app.pem. Make it readable by the user kōjō runs as and by nobody else. kojo setup github writes the key as github-app.pem into the directory given with --out (default secrets).

Run it as a service

deploy/systemd/kojo.service runs kojo serve as the system user kojo. Its header lists the install commands:

sudo useradd --system --create-home --home-dir /var/lib/kojo --shell /usr/sbin/nologin kojo
sudo usermod -aG kvm kojo
sudo install -d -m 0750 -o root -g kojo /etc/kojo /etc/kojo/secrets
sudo install -m 0640 -o root -g kojo kojo.yaml /etc/kojo/kojo.yaml
sudo install -m 0640 -o root -g kojo .env /etc/kojo/kojo.env
sudo install -m 0644 kojo.service /etc/systemd/system/kojo.service
sudo -u kojo -H sbx login
sudo -u kojo -H sbx policy init deny-all
sudo systemctl daemon-reload
sudo systemctl enable --now kojo

What the unit does:

Directive Effect
EnvironmentFile=/etc/kojo/kojo.env Loads the variables kojo.yaml names and the provider keys.
ExecStartPre=... kojo config validate A config that does not validate fails here, with the reason in the journal, instead of in a restart loop.
ExecStart=... kojo serve -f /etc/kojo/kojo.yaml --log-format json Runs the server. It applies pending migrations when it starts.
Restart=on-failure, RestartSec=5s Restarts after a crash.
TimeoutStopSec=90s Gives sessions time to checkpoint on stop.
StateDirectory=kojo /var/lib/kojo, the only place the service may write. sbx’s own files and the kits kōjō generates for it live there.
ProtectSystem=strict, NoNewPrivileges=yes, an empty CapabilityBoundingSet Hardening. PrivateDevices, PrivateTmp and ProtectHome are left out because sbx needs /dev/kvm and its per-user daemon.

Check the running server from the same host:

set -a; . /etc/kojo/kojo.env; set +a
kojo doctor --remote --token "$KOJO_ADMIN_TOKEN"

TLS

kōjō serves plain HTTP on server.listen. Put a reverse proxy that terminates TLS in front of it, and set server.public_url to the https:// address. kojo doctor warns while the public URL is not https.

The proxy forwards every path to kōjō: the dashboard, the API under /api/v1, the forge webhooks under /webhooks/, Slack’s HTTP mode, and MCP at /mcp. Three things matter for its configuration:

  • The dashboard polls and needs no special timeout. The MCP endpoint at /mcp may answer with a stream: raise the proxy’s read timeout if MCP clients come through it.
  • A webhook delivery can be up to 25 MiB; kōjō rejects larger bodies, and bodies that take longer than 30 seconds to arrive.
  • /healthz and /readyz need no authentication. /metrics is not on this port: it is on server.metrics_listen, 127.0.0.1:9090 by default, which only the host itself reaches. Scrape it from the host, and do not forward it.

A Caddyfile that does this:

kojo.example.com {
	reverse_proxy 127.0.0.1:8080
}

Forges must reach the public URL to deliver webhooks. Slack in socket mode needs no inbound connection.

Back up Postgres

Everything kōjō keeps is in Postgres. Back it up with pg_dump from the container:

docker compose exec -T postgres pg_dump -U kojo -d kojo -Fc > kojo.dump

Restore with kōjō stopped. --clean --if-exists drops the objects that exist before it recreates them from the dump:

sudo systemctl stop kojo
docker compose exec -T postgres pg_restore -U kojo -d kojo --clean --if-exists < kojo.dump
sudo systemctl start kojo

Not in the database, so back them up separately: .env, kojo.yaml and the GitHub App’s private key. docker compose down keeps the postgres-data volume; docker compose down --volumes deletes the database.

kojo config export writes the runtime config (skills, repositories, schedules, models, policies, access) as YAML. It is a readable copy for review and GitOps, not a backup: it holds no sessions, no audit log and no team memory.

Scroll to move. + - zoom, 0 fit, Esc close.100%