A recipe for running tole serve on a VPS so a client on another machine (a
desktop, a phone, a script) can use it with the live event stream. It is a
deployment recipe, not a new capability: no route, flag or default of tole
changes. What is here:
| File | What it is |
|---|---|
Dockerfile |
Multi-stage build of the release binary of tole-cli (default features), a Debian slim runtime, a non-root user (uid 10001), tole serve as the command, a HEALTHCHECK on GET /ready |
.dockerignore |
The build context is Cargo.toml, Cargo.lock, crates/ and scripts/container/ only |
scripts/container/ |
docker-entrypoint.sh (reads a secret file into TOLE_API_KEY), healthcheck.sh, stream_probe.py (the streaming and resume test client), smoke.sh (the image check CI runs before a push), image-tags.sh (the tag rules of the workflow) and its self-test |
.github/workflows/container.yml |
Builds the image on pull requests (no push) and publishes the nightly and the release channel to GHCR |
templates/container/compose.yaml |
tole plus one Caddy proxy; only the proxy publishes ports |
templates/container/Caddyfile, nginx.conf |
The proxy settings that keep the stream unbuffered |
No Docker on the VPS, or you would rather not use it? See vps-without-docker.md: the same layout as a systemd service with a TLS proxy on the host.
Status: run end to end on one Docker host (Docker 29.9.3) with a stand-in
model provider. The committed Dockerfile was built there on 2026-11-29 for
linux/amd64 with two differences the sandbox forced (no apt-get step: the
Debian package mirror is denied by its network policy, so the image used for the
tests has no git and no CA bundle; and the proxy's CA given to cargo, see "Re-run
on 2026-11-29"), and, on 2026-12-02, built again from the develop head on a local arm64 host
with no forced difference (216 MB unpacked, scripts/container/smoke.sh green).
"What was and was not verified" lists exactly what was exercised. The workflow
(.github/workflows/container.yml, #1015) builds and publishes the image to
GHCR as ghcr.io/codecoradev/tole in two channels (see "Channels and tags"): it
runs daily and is green through publish (2026-12-01 run), the package is public
(an anonymous pull of the nightly index, both platforms, verified 2026-12-02),
so a VPS can pull it as it is.
cd templates/container
umask 077
mkdir -p secrets
openssl rand -hex 32 > secrets/tole_serve_token # the serve credential
printf '%s' "$PROVIDER_KEY" > secrets/tole_api_key # the model provider key
sudo chown 10001:10001 secrets/* && sudo chmod 0400 secrets/* # required, see below
cp .env.example .env && $EDITOR .env # TOLE_DOMAIN, TOLE_BASE_URL, TOLE_MODEL
docker compose up --build -d
docker compose ps # tole: healthy
curl https://$TOLE_DOMAIN/health # {"protocol":1,"status":"ok","version":"..."}
curl -H "Authorization: Bearer $(sudo cat secrets/tole_serve_token)" \
https://$TOLE_DOMAIN/info # 200 {"features":[...],"protocolVersion":1,"version":"..."}/health and /ready answer without a credential (/ready is what the container
health check uses, /health is the liveness answer for a load balancer); /info needs the token, so a 200 there also proves
the token reached serve. Run scripts/container/stream_probe.py (below) once
before you rely on the stack.
The chown is required. Compose (without swarm) bind-mounts a file secret
exactly as it is on the host and ignores the uid, gid and mode of the
compose file, so a 0600 file owned by you is unreadable by the container user
(uid 10001) and serve stops at start with --token-file ...: Permission denied. The host files must be owned by 10001 (mode 0400) or be readable by
others; owner 10001 with 0400 is the narrow choice. You then read the token on
the host with sudo; keep a copy of it where your clients need it (a password
manager, the desktop's credential store), not next to the stack.
TOLE_BASE_URL, TOLE_MODEL and the key are used together: tole has no
built-in provider default, and with a blank TOLE_BASE_URL or TOLE_MODEL the
provider has to come from the user config in /data/codecora/tole/config.toml.
TOLE_DOMAIN is a public name that points at the VPS (Caddy fetches and renews
its certificate; ports 80 and 443 must reach it). With localhost Caddy uses
its own local CA, which your client does not trust until you install that root
or pass it (stream_probe.py --cafile, curl --cacert).
Keep secrets/ and .env out of version control (the repository .gitignore
lists both).
-
Builder. BuildKit is required (
RUN --mount=type=cacheandCOPY --chmod): the default of Docker 23 and later and ofdocker buildx; older engines needDOCKER_BUILDKIT=1. -
Binary.
cargo build --release --locked -p tole-cli, stripped, from the committedCargo.lock. Base images are pinned by tag and digest (the multi-arch index digest; bump both together). Build on the architecture you run. -
User. uid and gid 10001, no login shell,
USERset. The compose file also drops all capabilities, setsno-new-privileges, a read-only root filesystem (/tmpis a tmpfs) and a process cap. -
Listener.
tole serve --bind 0.0.0.0 --port 7801, plain HTTP, REST transport.0.0.0.0is only inside the container; the compose file publishes nothing for this service.--socketis not used: it needs a0700directory owned by the serving user, which a proxy in another container cannot enter.--transport mcpis not the default; override the command to use it. -
Token.
--token-file /run/secrets/tole_serve_token: a Docker secret, never an argument (visible inpsanddocker inspect). The token is trimmed of surrounding whitespace; an empty file stops serve.tole serverefuses to start without a credential. -
Provider key. tole reads it from the environment only. The entrypoint copies the file named by
TOLE_API_KEY_FILE(andTOLE_FALLBACK_API_KEY_FILE) intoTOLE_API_KEYand then execs tole. The value is in neither the compose file, the image nordocker inspect. tole marks itself non-dumpable at start and scrubs secret-shaped variables from every command it spawns (docs/threat-model.md, ENV-1 and #675). -
State. Two volumes; nothing is written into the image layer.
Path Holds /data/codecora(CODECORA_HOME)user config tole/config.toml(profiles, persona files,[sandbox], webhooks), cron store, discussion logs, trust records, skills/data/sessions(--sessions-dir)the session ledgers (append-only JSONL and their lock files) /data/home(HOME)the account home (for example a ~/.gitconfig)/workspace(--workspace)the folder serve is jailed to and the tools work in; a client's cwdmust be inside itThe ledgers are kept outside the workspace so the model's file tools cannot reach them (they are jailed to
/workspace); the model reads its own session's earlier entries, a compaction's dropped details included, only throughsearch_history(#1354), never the files. Commands the model runs are not confined that way, see "What the container does not add". Files are created0600and directories0700: the entrypoint setsumask 077and tole inherits it, so files the model's tools create in/workspaceget the same modes. That matters on a bind-mounted workspace a person on the host also edits; use a named volume or change theumaskline in the entrypoint. -
Health.
HEALTHCHECKrunshealthcheck.sh(bash/dev/tcp, no curl in the image):GET /readyon the container's loopback must answer200: the state directories (/data/codecora,/data/sessions) take a write, and with--cronthe ticker beats. It answers503when one does not (a read-only volume or one with no free inode shows up here; a volume that still has inodes but no free blocks is not proven to fail the probe) and while serve drains after SIGTERM.GET /healthis the liveness answer (the process is up) for a probe that must not fail on a full disk; a Kubernetes readiness probe uses/ready, a liveness probe/health. Neither takes a token (mobile-control.md, "GET /ready")./info(token needed) is for you to probe the version and the feature list after a deploy, not for the container check, which would otherwise have to hold the secret. -
Stop. SIGTERM drains for
--shutdown-grace(default 20 s; running turns are detached and stay resumable, see mobile-control.md "Shutdown"). The compose file setsstop_grace_period: 30s, above the grace; Docker's own default of 10 s would kill a drain in progress. -
Cron. Not on by default. To host the scheduler in the container, override the command with the same arguments plus
--cron. A bind-mounted workspace must be writable by uid 10001 (or run the service withuser:set to the owner's uid and gid).
Extra tools a workspace needs (a language toolchain, gh) are not in the image:
build your own FROM it and apt-get install what you need.
The image is ghcr.io/codecoradev/tole, for linux/amd64 and linux/arm64
(one multi-arch tag; Docker picks the platform). There are two channels, and
there is no latest tag: a bare docker pull ghcr.io/codecoradev/tole fails
on purpose, so nothing changes under a deploy that did not choose a channel.
| Channel | Built from | Tags | Moves? |
|---|---|---|---|
| Production | a release tag vX.Y.Z that is on main |
X.Y.Z |
never, one image per release |
X.Y |
to the newest final release of that minor (of the tags on main) |
||
stable |
to the newest final release (of the tags on main) |
||
sha-<7 hex> |
never | ||
| Nightly | the head of develop, once a day (03:17 UTC; skipped when develop has no commit since the last nightly) |
nightly |
every night, to the newest |
nightly-YYYYMMDD |
never, that day's build | ||
sha-<7 hex> |
never |
A prerelease tag (v1.0.0-rc.1) gets only 1.0.0-rc.1 and sha-<7 hex>: never
X.Y or stable. A version is vX.Y.Z with each part 0 or without a leading
zero and at most six digits, and a prerelease suffix is at most 40 characters;
anything else fails in the first job, before an image is pushed. The tag rules are
scripts/container/image-tags.sh, with a self-test.
What the workflow guarantees about the tags, how, and what it does not:
X.Y.Z,nightly-YYYYMMDDandsha-*are not re-pointed by the workflow. They are created only when the registry answers "not found" for them. Any other answer (a 5xx, a rate limit, an auth error) fails the job; it is never read as "absent".sha-<7 hex>names the first image built from that commit (a release at the commit of an earlier nightly keeps the nightly'ssha-tag). Not guaranteed: someone with write access to the package can still delete or move a tag by hand, and a registry that wrongly answers "not found" for a tag that exists would let it be re-created (the check cannot see past the registry).stableandX.Ymove forward only. "Highest" is computed over the final release tags that are onmain(git tag --merged origin/main), so a stray or refused tag (one not onmain, or malformed, likev999999999999.0.0) never counts and cannot freeze them. The list is read again in thetagsjob right beforepublishmakes the tags, so a run that started earlier cannot takestableback. A re-run of an old release leavesstableandX.Ywhere they are. A few seconds pass between that read and the tag write; two release runs are serialised by the shared group, so this is not a race between releases.nightlyonly moves to the head ofdevelop. A run whose commit is not the head ofdevelop(a re-run of an old nightly) builds and tests but publishes nothing, and says why in its summary. Ifdevelopmoves while a nightly builds, that run keeps its exact tags and leavesnightlyalone. A scheduled nightly is skipped whensha-<7 hex>of the head exists; if an earlier run died after writing it but beforenightlymoved, start a manual run (it does not skip).- The tags of one run point at one image, and a re-run completes them.
The tags are written by one
imagetools createcall, anchor first (X.Y.Zfor a release,sha-<7 hex>for a nightly). On a re-run, if the anchor exists, the run first checks that its image carries this commit in theorg.opencontainers.image.revisionlabel (pulled and read; a missing label or another commit fails the run, which is what a release tag deleted and pushed again on another commit looks like), and only then points every missing tag at the anchor's digest, not at the rebuilt image. To repair a re-pointed tag, delete the package version that carries the oldX.Y.Z(GitHub, organisation Packages,tole, the version list; its tags go with it) and re-run; checkstableandX.Yafterwards. Not guaranteed: the order in whichimagetools createwrites the tags of one call was not verified. If it dies half way and the anchor was not written yet, a re-run finds no anchor and points all tags at its own rebuilt image: still one image per tag set, but a different digest of the same commit than the half-written tags had for a moment. - What is pushed is what was tested. Each platform is pushed by digest first, then that digest is pulled and smoke-tested; tags are made only after both platforms passed. A digest that failed the test stays in the registry untagged.
- Credentials. The checkouts keep no token in
.git. The job that pushes (build-push) drops its registry login (docker logout) before it runs the checked-out smoke script. The job that writes the tags (publish) has no checkout and runs no file of the repository; the tag list comes from thetagsjob, which has nopackagespermission. - Order. Every release run shares one concurrency group and every nightly run
another, so two tags pushed together are published one after the other. GitHub
keeps one pending run per group and cancels an older pending one: when you
push several release tags within minutes, look at the Actions list and re-run
any release run that shows "Cancelled" (the re-run is safe, see above). There
is no alert for that, so the
planjob of every release run lists the earlier release tags onmainthat have noX.Y.Zimage (only tags whose tree has this workflow) as a warning and in the job summary, with the re-run instructions; a registry error there counts as "could not check", never as "missing".
Which tag to pull
| You want | Pull | Why |
|---|---|---|
| A VPS deploy | ghcr.io/codecoradev/tole:0.12.0 (an exact version) |
Changes only when you edit the tag, after reading the CHANGELOG. Recommended. |
| A VPS that follows releases | ghcr.io/codecoradev/tole:stable |
Moves to each final release on docker compose pull; you take every release, including a BREAKING one, unread. Pair it with the checklist's backup and a staging run. |
| To try what is coming | ghcr.io/codecoradev/tole:nightly |
The head of develop: not a release, can break, not for data you cannot lose. |
| An exact build, forever | ghcr.io/codecoradev/tole@sha256:<digest> (compose: TOLE_IMAGE_TAG=0.12.0@sha256:<digest>) |
A digest never changes. It is printed in the summary of the workflow run that published the image (Actions, "Container image", the publish job); docker buildx imagetools inspect ghcr.io/codecoradev/tole:0.12.0 shows it later. |
| A build of one commit | ghcr.io/codecoradev/tole:sha-0123abc |
The first image built from that commit, nightly or release. |
With the compose file of this recipe:
cd templates/container
# .env: TOLE_IMAGE=ghcr.io/codecoradev/tole TOLE_IMAGE_TAG=0.12.0
docker compose pull tole && docker compose up -d --no-buildTo follow a channel, set TOLE_IMAGE_TAG=stable (or nightly) and repeat those
two commands whenever you want the newest; compose recreates the container on the
same volumes (see "Persistence and upgrades"). Check what is running:
docker compose exec tole tole --version, or GET /info with the token.
Rolling back. The ledgers are append-only and older binaries cannot be
assumed to read what a newer one wrote, so read the CHANGELOG of the versions
between before you go back, and back up the two volumes first. Then set
TOLE_IMAGE_TAG to the previous exact version (0.11.0) and run the same two
commands. To pin an exact build, append its digest: TOLE_IMAGE_TAG=0.12.0@sha256:<digest>
(Docker then ignores the tag and checks the digest).
Docker keeps the previous image locally until you prune it, so a rollback of a
deploy you just made needs no download: docker image ls ghcr.io/codecoradev/tole.
The digest of what runs now (the index digest, the one the workflow summary prints):
docker image inspect --format '{{json .RepoDigests}}' "$(docker compose images -q tole)".
It lists a digest only for an image that was pulled from a registry, not for one
built locally. (Written from the command line documentation; not run against a
real container here.)
Where the publishing runs. .github/workflows/container.yml:
- A pull request that touches the image recipe (Dockerfile,
scripts/container/,templates/container/, the workflow) builds both platforms and runsscripts/container/smoke.shon each (tole --version, uid 10001,tole servereacheshealthythrough the image's own HEALTHCHECK), and parses the compose file. It pushes nothing and never haspackages: write(theplanjob haspackages: read, to ask the registry what exists). A fork's pull request and a manual run from a branch other thandevelopdo the same. - The nightly (schedule, or a manual run from
develop) and a release tag push the image. Each platform builds on a native runner (no emulation), is pushed by digest and then pulled back and smoke-tested by that digest; a last job puts the tags on one index of the two digests and checks that both platforms are in it. A tag push is refused unless its commit is onmain(the same rule asrelease.yml), and the smoke test requirestole --versionto report exactlytole <the tag's version>. - A nightly publishes only when its commit is the head of
developand theCIworkflow run of that push todevelopsucceeded (still running, missing or red: the run builds and tests but publishes nothing, and the next night tries again). A manual run has the inputskip_ci_gatefor the first package creation or a repair. The gate is the wholeCIworkflow, so an unrelated red job holds the nightly back; that is on purpose. - Only the two jobs that push have
packages: write, and only when the repository iscodecoradev/tole. - Not published with the image: a signature, an SBOM or a provenance attestation
(the workflow builds with
provenance: falseandsbom: falseso the two platform images merge into a clean index); the image carries no sandbox tooling (#1016).
One-time steps for the owner (a workflow cannot do them):
- Run the workflow once (Actions, "Container image", "Run workflow", branch
develop; tickskip_ci_gateif CI of the head is not green). It creates the package. - Make it public: GitHub, organisation
codecoradev, Packages,tole, Package settings, Danger Zone, Change visibility, Public. (If the button is greyed out, an organisation owner has to allow public packages first: organisation Settings, Packages, Package creation, tick Public.) There is no API for this setting. Check it from a machine that is not logged in:docker logout ghcr.io; docker pull ghcr.io/codecoradev/tole:nightly. - Check the repository link: the package page shows
codecoradev/toleunder "Repository". The image labels and index annotation carryorg.opencontainers.image.source, which links it; if it is missing, use Connect repository on the package page. Under Manage Actions access the repository must be listed with Write (it is, when the workflow created the package; add it by hand if the package was pushed from elsewhere first). - Optional, recommended: an Environment on the two pushing jobs. Repository
Settings, Environments, New environment (name it
container-publish), Deployment branches and tags, Selected branches and tags, add the branchdevelopand the tag patternv*; then addenvironment: container-publishto the jobsbuild-pushandpublishof the workflow (two lines). See "Known limits" for why. - Optional: add the
Container imagebuild check as a required check ofdeveloponly if every pull request should run it; it is path-filtered, so a required check would block pull requests that do not touch the recipe. Leave it advisory.
Known limits (left as they are, on purpose):
- A pull request can change the workflow. A pull request from a branch of this
repository runs the workflow text of that branch, and a collaborator who can push
a branch could edit it. The guarantees for pull request runs (no push, no
packagespermission, never a fork) are only as strong as the text of the workflow that review approves; branch protection and review of the workflow file are what hold them. The Environment above is the technical backstop: a job in it can only run fordevelopandv*tags. - Floating action versions hold the token. The workflow uses
actions/*anddocker/*at a floating major, as every workflow of this repository does, and those steps run with theGITHUB_TOKENof the pushing jobs, which can write the package. Dependabot (github-actions, weekly) keeps them current; pinning to a full commit is a repository-wide decision, not made here. - The nightly's gate is the smoke test and the
CIrun of the commit, not the other workflows (security scans, perf budget).
No secret and no repository variable is needed: the workflow logs in with the
run's GITHUB_TOKEN.
The ledgers, user config, cron store and the workspace are on the tole-data
and tole-workspace volumes, so removing or replacing the container keeps
them. An upgrade of a locally built image is docker compose up --build -d, of a published one docker compose pull tole && docker compose up -d --no-build ("Channels and tags"): compose stops the old
container (drain, see above) and starts the new one on the same volumes; a turn
that was running is detached and resumes with the next prompt
(POST /sessions {"resume": id}, mobile-control.md). The ledgers are append-only
and a newer binary reads them as tole resume does; read the CHANGELOG for the
version step first. Do not run two servers on the same
/data/sessions (each session file has a writer lock; a second writer gets
409). To back up, copy the volume while the service is stopped:
docker run --rm -v tole_tole-data:/data -v "$PWD":/b debian:bookworm-slim tar czf /b/tole-data.tgz -C /data .
(the volume name is prefixed with the compose project name).
Disk growth. Nothing in tole removes or rotates a settled session file or a
spilled image: the ledgers and /data/codecora/tole/images only grow, and they share the
tole-data volume with the config and the cron store, so a full volume stops all
of it. GET /ready fails on a read-only volume (its state check creates and
removes an empty file in /data/sessions and in the tole data directory under /data/codecora), but it is a
write probe and not a space alarm: watch free space from the host (df -h, the
orchestrator's volume metric). To see what is using it:
du -sh /data/sessions /data/codecora/tole/images and ls -lS /data/sessions | head
inside the container. Retention is decided and built in small steps (#1020):
tole sessions and tole doctor print the number of session files, their bytes,
the largest and the oldest, and tole sessions archive --to DIR --older-than DAYS
moves whole, settled session files that were last written more than DAYS days ago
to a directory you name (a dry run that lists what it would move; --execute does
the move). Run it by hand from a terminal in the container (docker exec -it), with
--sessions-dir /data/sessions when the process was started with it and a --to
on the volume you want the bytes to go to (a directory on the same tole-data
volume frees no space; mount a second volume for it). It copies, verifies the copy
byte for byte, fsyncs, and only then removes the original, so an interruption
leaves the whole file in one place or both; it never deletes a session, never runs
by itself and is refused for an agent session. The directory must be owner-only
(chmod 700); an archived session is no longer found by tole resume: read or
continue it with --sessions-dir DIR, or move the file back with mv -n (never a
plain mv, which overwrites a new session that reused the id), and never delete a
*.lock file in /data/sessions while any tole process is running. Images
(/data/codecora/tole/images) are not moved: they stay an operator cleanup. See
session-retention-design.md, section 10 (sizing the
volume), section 12 (the decisions) and section 13 (the command as built).
tole serves plain HTTP; TLS ends at the proxy the owner runs (decision D6 of
desktop-design.md requires https:// for a non-loopback
server; D5, that reach is the owner's own means and tole ships none, is still
awaiting the owner's confirmation and is what this recipe assumes), or the owner uses a private network
(WireGuard, an SSH tunnel) and no public proxy at all.
The stream is GET /sessions/{id}/events?after=<seq>: Server-Sent Events
(text/event-stream, HTTP/1.1, the response is ended by closing the connection,
not by a length). tole sends Cache-Control: no-cache and
X-Accel-Buffering: no, and a : ping comment after 15 s without a write
(TOLE_SERVE_HEARTBEAT_SECS, 1 to 3600). There is no WebSocket. What the proxy
must do:
| Setting | Why | Caddy | nginx |
|---|---|---|---|
| Do not buffer the response | A buffer holds text_delta frames until it fills or the turn ends |
flush_interval -1 (Caddy also flushed text/event-stream unbatched without it in the test; keep it) |
proxy_buffering off (tole's X-Accel-Buffering: no alone also works; the setting does not rely on it) |
Do not compress text/event-stream |
A compressor waits for a full block | no encode block |
gzip off |
| Read timeout above the heartbeat | An idle stream carries only a ping every 15 s | none by default | proxy_read_timeout (the template: 3600 s) |
No short read timeout on POST .../prompt |
It answers when the turn ends, which can take minutes, with no byte before that | none by default | proxy_read_timeout: the template's 3600 s is a choice, a longer turn is cut |
Send request bodies with a Content-Length |
tole refuses chunked request bodies: any Transfer-Encoding header is a 400 (serve.rs, request smuggling guard) |
request_buffers 12MB: fixes a body of unknown length from an HTTP/2 client (tested, Caddy 2.11.9) but not a chunked HTTP/1.1 body, which is still forwarded chunked and answered 400. tole-client sends a Content-Length, so it is not affected; use the nginx recipe for a client that sends chunked bodies |
the default request buffering does it; never proxy_request_buffering off |
| HTTP/1.1 to the upstream | tole speaks HTTP/1.1 | transport http { versions 1.1 } |
proxy_http_version 1.1 + Connection "" |
| Body cap above 10 MiB | An authenticated image upload is accepted up to 10 MiB | request_body max_size 12MB |
client_max_body_size 12m |
A proxy with an idle timeout shorter than 15 s needs a lower
TOLE_SERVE_HEARTBEAT_SECS (the compose file passes it through).
A dropped connection loses nothing durable: reconnect with
?after=<last seq seen> (or the Last-Event-ID header) and the missed entry
frames are replayed, once each, then ready. Ephemeral frames (text_delta,
reasoning, tool start and finish) are not replayed; the final answer is always
an entry. After a client-side break of POST .../prompt, read GET /entries
and busy before sending again (mobile-control.md and desktop-design.md 3.4).
At most 8 streams are open per server, shared by all clients.
python3 scripts/container/stream_probe.py https://$TOLE_DOMAIN \
--token-file templates/container/secrets/tole_serve_token \
--cwd /workspace [--cafile caddy-root.pem | --insecure]It starts a session, opens the stream, sends a prompt, and prints the time from
sending the prompt to the first text_delta frame, the number of frames, and
the gap between them (a buffering proxy shows one burst at the end of the turn,
and the probe says so and fails). Then it cuts the stream in the middle of a
second turn, reopens it with after=<last seq> and compares what arrives with
GET /entries. A stream silent for more than --stream-timeout (default 120 s) counts as broken:
raise it if you set TOLE_SERVE_HEARTBEAT_SECS above 120. It exits 0 when both
checks pass, 1 when one fails (including a prompt that did not succeed) and 2
when it could not decide (the turn ended before the cut, or the log had nothing
to resume). It spends one prompt per phase on a real provider. Run it
against serve directly and through the proxy and compare the first-frame time;
to measure first token against first frame exactly, point TOLE_BASE_URL at a
mock provider that logs when it emitted its first token.
Read threat-model.md ("Remote approver trust boundary (#200)", "Event streams (#524)", "Phone as approval surface (#202)", "Remote serve in a container (#1044)") and desktop-design.md 3.2 and 3.3 first. In short:
- The serve token is approval authority. Whoever holds it can read every
transcript, start turns and approve Writes on the box. The shared token has no
scope and no revocation short of changing the secret and restarting; a
per-device token (#1320,
tole serve token add,read-onlyorfull) is revoked alone with no restart. Treat it like an SSH key:openssl rand -hex 32, a file, not in a chat or a shell history, rotate on any doubt. - Public exposure invites a lock-out. The failed-auth limiter (10 a minute)
counts per source address, and behind the proxy that address is the proxy's:
tole does not read
X-Forwarded-For. Anyone on the internet who sends ten wrong tokens in a minute makes every request, the owner's included, answer429until the window passes. A 256-bit token makes guessing hopeless but not the lock-out. Prefer a private network (WireGuard, Tailscale-like, an SSH tunnel) or restrict the proxy to the addresses you use; the nginx template adds a request-rate limit, which only slows a flood. Do this at the proxy; tole has nothing to restrict it by. /health,/readyand the webhook routes need no token./healthtells anyone the exact tole version;/readytells anyone whether serve works (200or503, no detail; the failing check only with the token). Webhook routes keep their own HMAC gate; a route configuredinsecure_loopbackis refused by serve on a non-loopback bind, which0.0.0.0is.- HTTP between the proxy and tole. The traffic on the compose network is
unencrypted, and any other container on that network can reach
tole:7801with a token it learned. Keep the network to these two services. --auth basicworks in the image (override the command) but a non-loopback bind needs--allow-insecure-basic, which says only that TLS ends in front; it does not check that it does.- Rate limits, request caps, the jail. Unchanged and in force: 32
connections, 8 streams, a 1 MiB body before authentication, a client
cwdmust resolve inside--workspace.
The tole process and everything it starts run as an unprivileged user in a container whose writable parts are two volumes, with no published port, no capabilities, no privilege gain and a process cap. A bug in a tool or a command the model runs reaches the volumes and the container network, not the VPS's files or its other services.
The Caddy service gets the same treatment: no capability, no-new-privileges,
a read-only root filesystem (/tmp is a tmpfs) and a process cap. It still
binds 80 and 443 with cap_drop: [ALL] because Docker sets
net.ipv4.ip_unprivileged_port_start=0 inside a container (run on Docker 29.9.3;
on rootless Podman or a host that overrides the sysctl, add
cap_add: [NET_BIND_SERVICE]). With the name localhost Caddy logs one error
because it cannot install its local root CA into the container's trust store;
it is harmless, and a public name does not trigger it.
The container is not the command sandbox of sandbox-design.md and does not replace the approval gate:
- Commands run with the full authority of uid 10001 in the container. They
can read the secret files (
/run/secrets/*are readable by that user, and tole's non-dumpable flag and environment scrub protect only the process and its environment, not files), the config and ledgers in/data, and write the workspace. An approvedcat /run/secrets/tole_serve_tokenhands the model the approval authority. So approve commands as you would on a bare host, and do not pass broad--allowpatterns to a serve that has a model attached. - The network is open. The container has outbound access (it must reach the provider), so a command can send the workspace or a secret anywhere. There is no egress filter in this recipe.
- Docker's boundary is a shared kernel. It is weaker than a virtual machine; do not put a second tenant's data on the same host.
- The command sandbox is off and is not installed. tole's bubblewrap sandbox
for
run_command,job_startand MCP servers is opt-in ([sandbox]and[sandbox.consumers]in the user config) andbwrapis not in the image;tole doctorinside the container sayssandbox: backend unavailable (bubblewrap (bwrap) is not on an absolute PATH entry ...)and warns thatverifyandturnendwould run unsandboxed (doctoris notserve: what a serve does with them is theoptionalsentence below, which was not tested here). It needs unprivileged user namespaces, which a container usually forbids. One data point, not a bubblewrap test: on Docker 29.9.3 with its default seccomp profile,unshare --user --map-root-user trueas uid 10001 in the pinned Debian image fails withOperation not permitted, and succeeds with--security-opt seccomp=unconfined. Whetherbwrapitself then works, whatoptionalandrequireddo in each case, and which setup the image should ship is the open measurement of #1016; this recipe does not claim an answer. Enabling user namespaces means relaxing the container (a custom seccomp profile,apparmor=unconfined, or aCAP_SYS_ADMINgrant), which removes part of what the container gave you. Note that intole serveanoptionalsandbox counts asrequired(nobody can answer a prompt), so configuring a sandbox that cannot start makes the consumer refuse to run rather than fall back (sandbox-design.md, threat-model.md #601). A host with rootless Podman or a VM per tenant is the stronger answer; this recipe does not provide it. - Secrets are protected from the host's views, not from the user. A Docker
secret keeps the value out of the image, the compose file and
docker inspect;rooton the VPS and the container's own user can read it. - One user. There is one credential and no identity bound to a session.
What a leaked serve token allows today (nothing here is mitigated by the container; the container only bounds where it lands):
- Read every transcript the API serves (the sessions in
/data/sessions, including what the model read from the workspace). - Start turns on your provider key and your bill, and send prompts.
- Approve the Writes the model asks for. Every non-ReadOnly tool waits for an
approver, and the token holder is that approver. With it, an attacker can have
the model run commands as uid 10001 in the container: read
/workspaceand/data, read the secret files (cat /run/secrets/tole_api_keygives away the provider key), and send anything out over the open network. - It does not give a shell on the VPS or access outside the container's volumes, unless a command escapes the container (shared kernel, see above).
- The shared token has no scope and no revocation list; per-device tokens (#1320) have both, and this page does not depend on them.
Rotate (also after a laptop is lost, a screen was shared, or on any doubt;
tested on the compose stack, old token 401 and new token 200 afterwards):
cd templates/container
umask 077
openssl rand -hex 32 > secrets/tole_serve_token.new
sudo chown 10001:10001 secrets/tole_serve_token.new && sudo chmod 0400 secrets/tole_serve_token.new
sudo mv -f secrets/tole_serve_token.new secrets/tole_serve_token
docker compose restart tole # or: docker compose up -d --force-recreate toleThe restart is what makes the old token stop working: serve reads the file once
at start, so until then the old token is still accepted. A turn that was running
is detached and resumes with the next prompt; nothing in the ledger is lost.
Then put the new token into every client (the desktop's credential store, a
script) and check curl -H "Authorization: Bearer <old>" .../info answers 401.
If the token could have been used, also read the transcripts since the leak for
commands you did not start, rotate the provider key the same way
(secrets/tole_api_key, then the restart; revoke the old one at the provider)
and treat anything in /workspace and /data as seen. The proxy's certificate
is not involved.
tole serve has no TLS of its own, and the token is a bearer credential that
travels in the Authorization header of every request, the event stream's
included. On plain HTTP over the internet anyone on the path (a Wi-Fi, an ISP, a
proxy) reads it once and holds approval authority until you rotate; the same
path reads every transcript and can alter an approval answer in flight. That is
why the compose file publishes nothing for tole (it listens on 0.0.0.0
only inside the compose network), the only published ports are the proxy's, and
the client side refuses it: tole-client and the desktop (decision D6) require
https:// for any non-loopback server, except a network the owner marks as
private (WireGuard, an SSH tunnel). If you do not want a public proxy at all, keep the
stack on a private network and publish nothing. Never -p 7801:7801 on a public
address, and do not put the token in a URL.
Before you run it on a VPS:
- Domain name points at the VPS, ports 80 and 443 reach the proxy, and the provider's firewall allows nothing else inbound (no 7801).
-
docker compose psshowstolehealthy and noports:on it;curl http://<vps-ip>:7801/healthfrom outside does not connect. -
https://<domain>/healthis200and.../infois401without the token and200with it. -
secrets/is owned by 10001 and0400, not in git, not in a chat or a ticket; a copy of the token is in your password manager only. -
TOLE_IMAGE_TAGis an exact version (or a digest) of the production channel, or a version you built; notnightly, and there is nolatest; you read the CHANGELOG step before an upgrade. -
scripts/container/stream_probe.pythrough the proxy exits 0 (firsttext_deltaframe within a few hundred milliseconds of the prompt, frames spread over the turn, resume withafter=<seq>equals the log). - You know a failed-auth flood on a public name locks you out (
429, see the threat model): restrict the proxy to your addresses, or use a private network. - The model's commands are approved one by one: no broad
--allowpattern on a serve with a model attached; you know they run as uid 10001 with open network and can read the secret files. - Backups: the two volumes are copied while the stack is stopped, and you have restored one once.
- A rotation was rehearsed: you know the three commands above and where each client keeps the token.
Decided by the owner (2026-11-28) and implemented by container.yml:
- Registry and visibility. GHCR, a public package
(
ghcr.io/codecoradev/tole), linked to the repository. Making it public is a one-time owner step ("Channels and tags"). - Tags. Two channels (nightly from
develop, production from a release tag), exact and floating tags, nolatest. Alatestwould be one more name forstablethat a deploy can follow without choosing; the workflow has none. - When. The nightly from
develop(schedule or manual), the production channel only from avX.Y.Ztag that is onmain; a pull request only builds. It is a separate workflow on the same trigger asrelease.yml(a tag push), not a job ofpublish.yml: the image builds from the checked-out tag with--lockedand does not use crates.io, so it needs no order against the crates publish, andpackages: writestays out of the workflow that holds the crates.io token. - Platforms.
linux/amd64andlinux/arm64, each on a native runner (release.ymlalready builds onubuntu-24.04-arm). The Dockerfile was never built on arm64 before this workflow; a failing arm64 build fails the run, so the first nightly is where it shows, before any release. - Provenance. Not done: no signature, SBOM or attestation. Still open for
the owner. (
packages: writeis limited to the two pushing jobs.) - A build-only job for pull requests. Done (path-filtered).
- Sandbox in the image (bubblewrap, a seccomp profile): decided by #1016, not here.
Still open on #1015: a retention rule for the
daily nightly-YYYYMMDD tags (they accumulate; a cleanup job is a follow-up).
The image and binary sizes are recorded in docs/perf.md (2026-12-02), and the
image is built on headless CI runners on both platforms by the nightly.
First run, 2026-11-28 (the "Re-run on 2026-11-29" below supersedes it where
they overlap). One Linux host with Docker Engine 29.9.3 and Compose 5.7.1.
The sandbox that ran it had no route to the Debian package mirror
(deb.debian.org is refused by its network policy), so at that time the image of
the committed Dockerfile was not built: its apt-get install ca-certificates git
step cannot run there. What was done instead, and what that does and does not show:
- The build stage, as written:
cargo build --release --locked -p tole-cliin the pinnedrust:1.97.0-slim-bookworm@sha256:6d22...image, with the host's crate cache mounted read-only and--network none(--offline). It builds with the committedCargo.lockin 4 min 55 s at 3 jobs, and the stripped binary is 24 MB (tole 0.12.0). The BuildKit cache mounts of the Dockerfile were not exercised. - A test image made from the runtime stage of the Dockerfile with only two
differences: the
apt-getstep removed (so nogit, no CA bundle, no/etc/ssl/certs) and the binary copied from the build above. Everything else (user 10001,/dataand/workspace, volumes,ENV, the entrypoint and health check scripts,HEALTHCHECK,CMD) is byte for byte the Dockerfile's. That image is 148 MB; the real one is larger by whatgitandca-certificatesadd, not measured. It cannot reach an HTTPS provider (no CA bundle), which the tests did not need (the provider was a plain-HTTP stand-in). - The compose file, unchanged but for the Caddy hardening,
docker compose up --no-build -dwith that test image:tolereachedhealthy(the realhealthcheck.shinside the container; that run used the script as it was then, withGET /health, and was not repeated after #1318 moved it toGET /ready), the proxy started after it, and with the secrets owned by root and mode0600the stack failed as documented (entrypoint exit 64, restart loop) and with owner 10001 and0400it started. Inside the running container: uid 10001, root filesystem read-only (a write to/usrfails), no capability on either service, the token on no command line and the provider key in nodocker inspectoutput (only the_FILEname). - Through the proxy, Caddy 2.11.9 (the compose service) and nginx 1.27 (the
nginx.conftemplate with only the listen port andproxy_passhost changed, joined to the compose network):/health200over HTTP/2,/info401without and200with the token, HTTP redirected to HTTPS (308), no port oftolepublished (127.0.0.1:7801on the host does not connect). stream_probe.pythrough both proxies against a realtole servein the container with a stand-in OpenAI-style provider (a script that sends 40 chunks 250 ms apart, no real model): through Caddy the firsttext_deltaframe came 11 to 14 ms after the prompt was sent, through nginx 12 ms, straight at the container 4 ms (the proxy's own cost is about 7 to 10 ms); 40 frames over 9.77 s with a median gap of 250 ms and a maximum of 251 to 254 ms, in all three; the resume check passed each time (stream cut after 3 entries,after=6delivered the one entry the log had after that). The model was a stand-in: the numbers show what the proxy does, not a real provider's latency.- A buffering control, with a mock upstream: nginx with
proxy_buffering onand noX-Accel-Bufferingbatched all six frames at the end of the response; the template withproxy_buffering offdelivered them 0.5 s apart, also when the upstream sent noX-Accel-Bufferingheader. Caddy delivered them 0.5 s apart withflush_interval -1, and also without it (it flushestext/event-streamby itself; the setting stays as a safeguard). - Request bodies with a mock upstream that reports what it received: nginx
forwards a
Content-Lengthfor HTTP/1.1 chunked and HTTP/2 bodies; Caddy withrequest_buffersdoes it for HTTP/2 only, and forwards an HTTP/1.1 chunked body chunked (see the table above). caddy validateof the Caddyfile andnginx -tof the nginx template (with a throwaway self-signed certificate): both pass.docker compose configparses the compose file.- Persistence. With sessions written,
docker compose restart toleand then a recreate of the service from a re-tagged image (an upgrade rehearsal, same binary) left the two ledger files on thetole-datavolume (mode0600, owner 10001);POST /sessions {"resume": id}reopened one andGET .../entriesreturned the whole transcript. (GET /sessionslists only the sessions the running server hosts, so it is empty after a restart; that is not data loss.) An idle stop and start took about half a second. - Rotation, as in the section above: old token
401, new token200after the restart, and while the old process was still running the old token was still accepted. tole doctorinside the container (without the entrypoint's environment, so its "provider is not configured" line is an artefact ofdocker exec): no bubblewrap,verifyandturnendwarned as unsandboxed.- The earlier, no-daemon checks (build context under
.dockerignore,cargo checkin a scratch copy, the entrypoint and health scripts against a stub) were not repeated; the runs above supersede them where they overlap.
Re-run on 2026-11-29 (same Docker Engine 29.9.3, develop at bdb0d28, still
no route to the Debian mirror). This time the committed Dockerfile itself was
built with docker buildx build, from a copy that differs in exactly two places,
both forced by the sandbox and neither touching what the page claims about the
image: (1) the cargo build step gets CARGO_HTTP_CAINFO, SSL_CERT_FILE and
HTTPS_PROXY and a read-only mount of the sandbox proxy's CA (the sandbox
re-terminates TLS, and the build container does not trust its CA); (2) the
apt-get update && apt-get install ca-certificates git lines are removed (the
rest of that RUN, the user and the directories, is kept).
- The pinned base images (
rust:1.97.0-slim-bookworm@sha256:6d22...anddebian:bookworm-20261123-slim@sha256:e67e...) exist and pull by digest. - The build stage, as written, under BuildKit:
cargo build --release --locked -p tole-clifinished in 4 min 37 s (4 cores), with theRUN --mount=type=cachemounts,stripand the/out/tole --versioncheck in the sameRUN(tole 0.12.0); the binary is 24 MB. - The runtime stage:
COPY --from=build,COPY --chmod=0755of the two scripts,WORKDIR,USER 10001:10001,HEALTHCHECKandENTRYPOINTall built; the image is 149 MB withoutgitandca-certificates(the real one is larger by what they add; the real arm64 build of 2026-12-02 measured 216 MB unpacked,docs/perf.md). scripts/container/smoke.sh tole-serve:sandbox 0.12.0exits 0 on that image:tole --versionreportstole 0.12.0, the image runs as uid 10001, andtole servestarted the way the compose recipe starts it reacheshealthythrough the image's ownHEALTHCHECK(GET /ready, which supersedes the earlier run that used/health).- The binary of that image was also run outside Docker, which is what vps-without-docker.md rests on.
Not run, in that sandbox build: the apt-get install ca-certificates git step of the
Dockerfile (the 2026-12-02 local build ran the full Dockerfile, no forced
difference, and its sizes are recorded in docs/perf.md); the Caddy certificate path with a
public name (Let's Encrypt: only localhost and its local CA were run, with
--insecure in the probe); the nginx recipe on a host rather than in the
compose network; the stack with a real model provider; a stop during a running
turn (graceful drain in a container) on that host; tole serve --transport mcp or
--auth basic in the image; the desktop's remote entry; Podman; any
bubblewrap run (#1016); an external client from another machine; a published
image pulled by a second machine over the registry (the nightly publishes one;
nothing consumed it from a VPS yet).
- Retention of the nightly tags.
nightly-YYYYMMDDandsha-*images of the nightly channel accumulate in the package; a cleanup rule (for example keep the last 30 days) is not built. - Signature, SBOM, provenance attestation of the published image: owner decision, not built.
- The desktop's remote entry connects.
tole-clienthas an HTTPS transport since #1071 (threat-model.md, "HTTPS to a remote serve"), so it can connect to the proxy of this recipe. What is left is the desktop using it for a remote entry (a credential store and the connection page). - Acceptance criteria of #1044 still open: the compose example with a public name and a real certificate, the first-token-to-first-frame time measured against a provider that logs its first token (the stand-in provider here had no such log), a stop during a running turn, and the desktop entry.
- A way to keep the serve token unreadable by the model's commands. Start the
entrypoint as root with only
CAP_SETUIDandCAP_SETGID, open a root-owned0400secret on a descriptor, and drop to uid 10001 with--token-fd, so no file the user can read holds the token. It trades the "non-root from the first instruction" property for that; it is not built. - Real-IP handling. A trusted-proxy setting so tole's failed-auth limiter counts the client and not the proxy (a src change).
- Per-device tokens (#1320) are in; the rotation and leak sections above still
describe the shared token, and a lost device's token is revoked with
tole serve token revoke <name>(no restart).
Pre-run review (2026-11-28), written without a Docker daemon and without GitHub Actions. What was checked, by reading and by running what can run here:
- The workflow parses as YAML (PyYAML), every
run:block passesbash -n, and every${{ }}expression was read against the contexts GitHub allows at that place.actionlintandshellcheckwere not available. scripts/container/test-image-tags.shpasses (29 cases, the anchor first among them: both channels, forward-only floating tags, numeric version order, prerelease and its length cap, backport, stray malformed or huge tags in the list, leading zeros, nolatest, every refusal). The version match ofsmoke.sh(1.2.3does not match1.2.30or11.2.3) was run by hand on its own.docker compose configparsestemplates/container/compose.yamlwith the default variables and withTOLE_IMAGEandTOLE_IMAGE_TAGset to a GHCR image.
Since, on the runners: the workflow runs (the nightly schedule fired on
2026-11-29, 2026-11-30 and 2026-12-01, all green through publish on both
platforms, the smoke green on the pushed image, the package linked and public
with the anonymous pull verified on 2026-12-02) — so the pre-run questions
about a first run, docker build on both platforms, smoke.sh against a real
image, the GHCR linking and the visibility change are answered. So is the exact
text a registry gives for a tag or a package that does not exist: the first
publish (2026-11-29, green) matched the "not found" test, which looks for
MANIFEST_UNKNOWN, NAME_UNKNOWN, manifest unknown, name unknown,
not found and 404. Still not verified: the action versions (docker/*@v3/@v6
floating majors, like the other workflows; Dependabot bumps them); docker buildx imagetools create --annotation and the jq index check; the ubuntu-24.04-arm build
time of the Rust stage (the earlier amd64 build took 4 min 55 s at 3 jobs); the
gh api query of the nightly's CI gate and the concurrency expression (read, run
only through a jq stand-in for the gate); docker pull of a digest on the
arm64 runner; the re-run paths (anchor reuse, a develop head that moved), which
need a registry; that GitHub keeps a cancelled pending release run re-runnable; docker image inspect reading the revision
label of a pulled index on the runner; the write order of imagetools create for
several -t flags; the docker compose images -q and RepoDigests command in
"Rolling back"; the "release tags without an image" warning (it reads trees and
the registry; it has not run).