Repository navigation
feat(deploy): Docker Compose trial path for the P6 runtime (#342) - #345
Conversation
A second, additive deployment next to deploy/vm/: supervisor (with its fork()-based worker pool in ONE container), sandbox-relay, redis and one remote-worker sandbox under Docker Compose, fronted by a POSIX-sh `curl | sh` installer. deploy/vm/ stays the production path and is untouched. - docker-compose.yml mirrors deploy/vm/env/*.env.example var-for-var, with only addressing changed to service names. One SH_RELAY_PORT drives the relay bind and both dial addresses. SH_RELAY_TOKEN and SH_TURNS_PER_WORKER are required at `compose config` time. Only the supervisor's 8080 is published, on loopback. - install.sh writes a 0600 .env once (never clobbered), generates a 256-bit relay token when none is given, and never puts it on an argv. - tests: install.test.sh (docker/curl mocked, every other external shimmed, token-never-in-argv proven), compose.test.sh (asserts on Compose's own resolved config), images.test.sh; wired into make test-deploy. smoke.sh is the COMPOSE_LIVE_SMOKE=1 live gate. Fixes found by images.test.sh, needed for the published-image path: - Dockerfile never copied the supervisor/config-bundle manifests before `pnpm install`, so the image could not start the supervisor. - remote-worker/Dockerfile pinned golang:1.25 against go.work's 1.26, so the image did not build at all. - build.yaml now publishes serverless-harness-remote-worker, the sandbox compose defaults to. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The "no docker on PATH" case moved the mocks aside but left /usr/bin on PATH. Every GitHub runner has a real /usr/bin/docker, so install.sh found it and ran a real `docker compose up` (CI: "redis Pulling"); on macOS docker lives in /opt/homebrew/bin, so it passed locally. PATH is now the test's own bin dir alone, where every external is a mock or a logging shim, and the case asserts no docker is reachable before it runs. Reproduced in a Debian container with a stand-in /usr/bin/docker. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
mrsabath
left a comment
There was a problem hiding this comment.
Bel lavoro — for a PR that adds a curl | sh installer, a shared secret and a published port, the security surface is handled with real care. I verified the claims that matter rather than taking the prose for it.
Token handling holds up. generate_token produces 64 hex chars from /dev/urandom and differs across runs (ran it). umask 077 is set inside the subshell before the first byte lands, so the file is never briefly world-readable — the ordering is the part that's easy to get wrong, and it's right here. The token reaches containers through .env, never argv, and install.test.sh pins that with assert_not_in_argv rather than trusting it. env_file_value I exercised directly: it handles values containing = (cut -d= -f2-), picks the last duplicate, and returns empty-with-rc-0 for a missing key rather than failing.
Exposure is minimal and actually enforced. Only the supervisor publishes, and compose.test.sh asserts host_ip == "127.0.0.1" and target == 8080 exactly — not a substring match on the YAML, which is what makes it hold under refactors. Redis (no auth, holding sh:sandbox:records, so whoever writes to it picks the executor for every turn), the relay, and the unauthenticated admin listener all stay unpublished. On the sandbox service lacking user: while the other three set 1000:1000 — I checked remote-worker/Dockerfile and it ends on USER 1001, so the container is non-root from the image. Correct as written.
Both out-of-scope fixes are real, not speculative. I confirmed go.work declares go 1.26.0, so golang:1.25-alpine genuinely could not build the sandbox image. And packages/supervisor's manifest carries the tsx devDependency that command: [node, --import, tsx, src/main.ts] needs — with the manifest never COPYed before pnpm install, the published image had no node_modules for it. "The published image couldn't start the supervisor" is accurate. Fixing these here rather than deferring was the right call, since the compose path is the first thing that actually exercises them.
images.test.sh is the standout. It cross-checks compose's ${SH_*_IMAGE:-default} values against build.yaml's publish matrix — the drift that nothing else could catch, because neither file knows the other exists. What makes it trustworthy is the vacuity guards: it fails if either grep yields nothing, so it cannot quietly degrade into a test that asserts about an empty set. Same discipline in compose.test.sh:26, which fails rather than skips when Compose is absent. That is the difference between a suite that proves something and one that looks green.
Env parity is driven from the real files. check_mirror reads deploy/vm/env/*.env.example and walks its keys, with an explicit allowlist for the addressing that legitimately differs — so drift in either direction surfaces, rather than only additions on the compose side.
Two findings below, neither blocking. Finding 1 needs an unusual credential to trigger; finding 2 is a documentation gap.
On the live smoke
Using the sandbox container's own hostname as the assertion is a genuinely good choice — it is unguessable by a model and differs from the supervisor's, so a passing check is hard to fake. That is a much stronger proof of "the command ran in the sandbox, through the relay" than asserting on the turn succeeding.
Also worth noting: the PR body is explicit that install.sh was not verified against a real Docker daemon, and that the curl | sh path only works post-merge once build.yaml has published both images. Stating the gaps rather than letting a reviewer discover them is what let me spend the time on the parts that were verifiable.
Areas reviewed: Shell (installer, smoke, three test suites), Docker Compose, Dockerfiles, CI workflow, docs, secret handling, port exposure
Commits: 2 commits, both signed off (DCO pass)
CI status: passing (13/13)
| if [ -n "$is_set" ]; then | ||
| eval "value=\$$var" | ||
| # shellcheck disable=SC2154 # assigned by the eval above | ||
| printf '%s=%s\n' "$var" "$value" |
There was a problem hiding this comment.
suggestion — model values are written unquoted, and Compose's .env parser treats two characters specially in an unquoted value.
Per Docker's documented .env rules:
$is interpolated in unquoted (and double-quoted) values. A credential containing$loses everything from the$to the end of the token, substituting whatever that name expands to (usually empty).#starts an inline comment — "Inline comments for unquoted values must be preceded with a space." SoVAR=secret # noteresolves tosecret.
Which means a caller-supplied value survives the round trip only if it contains neither. Replicating this loop's output:
SH_MODEL_AUTH=sk-ant-abc$def -> compose resolves "sk-ant-abc" ($def interpolated away)
SH_MODEL_AUTH=sk-ant-abc # note -> compose resolves "sk-ant-abc" (truncated at " #")
SH_MODEL_BASE_URL=http://h/p?a=1&b -> fine
The generated SH_RELAY_TOKEN is immune — od -An -tx1 output is pure hex — so this is confined to the caller-supplied model credentials, and $ in an API key or a SH_MODEL_CUSTOM JSON blob is the realistic trigger. The failure mode is the unpleasant kind: the stack comes up, nothing errors, and the model call fails auth with a key that looks right in .env.
Single quotes fix it, since single-quoted values are used literally (no interpolation), with ' escaped:
value=$(printf '%s' "$value" | sed "s/'/\\\\'/g")
printf "%s='%s'\n" "$var" "$value"A test case would pin it — install.test.sh §5 already proves a key reaches .env and not argv, so extending it with a value containing $ and #, then asserting what docker compose config actually resolves, would close the loop. Right now no case uses a value with special characters, which is why this is invisible.
To be transparent about my own confidence: I could not run docker compose config to demonstrate this (the Docker CLI here is podman-backed with no running machine), so this is derived from the documented parsing rules plus the exact bytes this loop writes, not from an executed repro. The .env output I did verify directly. Worth a quick local check against a real daemon before acting on it.
Not blocking — it needs a credential with $ or # to bite, and the fail-closed paths are all unaffected.
| pool), the sandbox relay, Redis and one remote-worker sandbox, under Docker Compose. | ||
|
|
||
| **This is the trial path, not the production one.** For a dedicated VM or bare metal, use | ||
| [`deploy/vm/`](../vm/README.md) (`setup-vm.sh`, systemd units, podman). That path is the |
There was a problem hiding this comment.
nit — the PR description says "The README cross-links it," but that appears to be only this new file, not the root one.
The root README.md is not among the PR's changed files, and at 1480c9b it contains no occurrence of compose, deploy/vm, or trial (checked the whole 351-line file, case-insensitively). So a reader arriving at the repo root has no path to this trial.
This file's own back-links are right — deploy/vm/ as the production path, ../vm/env for the parity claim, and the "What the trial does not claim" section is the honest framing. It is only the forward link that is missing.
The root README already has the natural slots, all using the same relative-link style:
- §Quick Start (~line 124) — where
./deploy/knative/setup-kind.shis introduced - §Deploy on OpenShift (~line 152) — the sibling "here is another way to run it" section
- §Repository Layout (~line 289) —
deploy/knative/is listed;deploy/compose/anddeploy/vm/are not - §Documentation (~line 337) — a one-line entry alongside the OCP guide
One line in §Documentation would likely be enough. Flagging mainly because the claim is in the PR body: someone reading the description would reasonably believe the discoverability question is already settled.
Closes #342.
What
A second, additive deployment path,
deploy/compose/, for a no-root trial on a dev machine: supervisor + relay + redis + one remote-worker sandbox under Docker Compose, installed withcurl … | sh.deploy/vm/is untouched and stays the production path. The README cross-links it.fork()s its workers, so W scales withSH_WORKERSinside thesupervisorservice, never with replicas.compose.test.shfails on a second worker-bearing service or a replica count.deploy/vm/env/*.env.examplevar-for-var. Only the addressing changes (redis://redis:6379,sandbox-relay:<port>). OneSH_RELAY_PORTsets the relay's bind port and both dial addresses, so the "must agree" footgun is gone by construction.SH_RELAY_TOKENorSH_TURNS_PER_WORKERstopsdocker composewith the variable named.127.0.0.1. Redis (no auth, holdssh:sandbox:records), the relay and the admin port stay unpublished.install.sh(POSIX sh, runs fine from a pipe):.envonce and never clobbers it;docker-composewhen the plugin is missing.Fixes outside
deploy/compose/(each found by a failingimages.test.sh)Dockerfilenever copied thepackages/supervisororpackages/config-bundlemanifests beforepnpm install, so the published image couldn't start the supervisor: nonode_modules, notsx.remote-worker/Dockerfilepinnedgolang:1.25, butgo.workrequires 1.26. The image didn't build at all (go.work requires go >= 1.26.0).build.yamlnow also publishesghcr.io/rossoctl/serverless-harness-remote-worker. Nothing published a sandbox image that dials the relay.Tests
Each of these was seen failing first. The first three run in
make test-deploy, so CI'sdeploy-scriptsjob picks them up.tests/install.test.sh: runsinstall.shfrom a pipe undersh, with docker and curl mocked and every other external command in a logging shim. It provesSH_RELAY_TOKENnever reaches any argv. It also passes under dash with GNU tools (Debian container).tests/compose.test.sh: asserts ondocker compose config --format json(no daemon needed), not on the YAML text. It caught all 10 mutants I tried.tests/images.test.sh: the default images are onesbuild.yamlpublishes; the harness image installs every package compose runs; the builder's Go satisfiesgo.work.smoke.sh: the live gate, runs only withCOMPOSE_LIVE_SMOKE=1. Ran locally (podman behind the docker CLI, images built from this branch): 4/4. Two healthy workers;sh-sandbox-0recorded in Redis; a/turnreply carrying the sandbox container's hostname (which no model can guess, so the command really ran in the sandbox through the relay); the session persisted in Redis.Notes for review
curl | shpath works only after merge, oncebuild.yamlhas published both images frommain.install.shwritesSH_TURNS_PER_WORKER=4as a labelled trial value. The VM template still ships none, because for E8 it is a measured output.install.shagainst a real Docker daemon. It is covered by the mocked test, and the compose file by the live smoke.deploy/vm/setup-vm.shdefaultsSANDBOX_IMAGEtoserverless-harness-sandbox, which runssleep infinityand never dials the relay, so VM sandboxes can't attach. Worth its own issue.🤖 Generated with Claude Code