Deploy: one compose file, shapes chosen by profiles and env - #296
Merged
Conversation
Deployment shapes were a file per shape (compose.local.yaml, compose.remote.yaml) stitched onto the base via COMPOSE_FILE. Each new provider that needed different services was a new whole file duplicating the others — a combinatorial pile, since a shape is really a combination of orthogonal axes (which provider, whether an edge exists), not a single choice. Collapse to one compose.yaml. Every service lives there; the two genuinely optional ones — the Caddy identity edge and the janitor — are gated by profiles, and the per-provider drukbox differences (provider, tailnet, service token, bind host) were already env values, so they ride in .env exactly as exe vs generic- remote already did. install.sh writes COMPOSE_PROFILES instead of picking a file: empty for a local docker box, caddy,janitor for a hosted one. drukbox now listens on its image default port (8780) in every shape; the local overlay's :8000 override and matching healthcheck were incidental drift, so the docker shape's service_url moves to 8780 to match. (The from-source `make dev` flow in development.md keeps :8000 — that is bare uvicorn's default, unrelated.) A provider whose drukbox needs a structurally different shape — different mounts, a different user, an extra service — still warrants an overlay, because env can substitute values but cannot restructure a service. compose.docker-sbx.yaml is the first: it reshapes the drukbox services to drive the host's Docker Sandboxes daemon (microVM sandboxes) and adds the SSH gateway, selected by install.sh with COMPOSE_PROFILES=caddy,janitor,gateway when the provider is docker-sbx. Adding an env-only provider now costs zero new files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The gateway now extends the base drukbox anchor, and it gets the Postgres DATABASE_URL instead of the sqlite default from .env. Setup migrates the retired :8000 service_url of old docker-shape installs to :8780, and it renders SERVICE_TOKENS on every shape — the compose default is gone, and a missing token stops drukbox instead of accepting a known one. drukbox binds 127.0.0.1 through its own variable, not through the web bind variable that macOS sets to 0.0.0.0. install.sh writes the shape selection to .env before each exit path, and it removes the retired overlay files. The docker-sbx branch pins DRUKS_SBX_HOME (setup preserves it), creates the .drukbox bind source with the correct owner, and stops with instructions when the sandboxd socket is missing. The overlay requires DRUKS_SBX_HOME and does not fall back to the ambient HOME. One "hosted" profile replaces the paired caddy/janitor profiles. The full-local diagram shows the correct port. The deploy README documents the host preparation and maps the retired overlay files to their replacements. Comments and docs use simplified English (ASD-STE100). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
No legacy local-shape installs exist that upgrade in place. A stale value is a one-line manual edit, not a code path to keep forever. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Deployment shapes were a file for each shape:
compose.local.yamlandcompose.remote.yaml, stitched onto the base withCOMPOSE_FILE. Each provider that needed different services meant a new file that copied the others, because a shape is a combination of two independent choices: which provider, and whether an edge exists. A fourth file for docker-sbx would have copied Caddy and the janitor from the remote overlay.What
One
compose.yamlholds every service. The variation splits by kind:hostedprofile gates the Caddy edge and the janitor; thegatewayprofile gates the SSH gateway.install.shwritesCOMPOSE_PROFILESto.env: empty for a localdockerbox,hostedfor a hosted one,hosted,gatewayfor docker-sbx..env, as before for exe and generic remote.compose.docker-sbx.yamladds the mounts that connect drukbox and the gateway to the host Docker Sandboxes daemon. Only a provider with different mounts needs an overlay. An env-only provider costs zero new files.Safety and upgrade behavior
service_url = :8000in its druks.toml while drukbox now listens on:8780. There is no code migration on purpose: no such installs exist that upgrade in place. The fix on an affected box is one edit: setsandbox.service_urltohttp://127.0.0.1:8780.SERVICE_TOKENSrenders on every shape and compose has no default: a missing token stops drukbox instead of accepting a known one.127.0.0.1throughDRUKS_DRUKBOX_BIND_HOST, separate from the web bind variable that macOS sets to0.0.0.0.install.shwrites the shape selection to.envbefore each exit path (a setup gaps-exit included), removes the retired overlay files, and for docker-sbx: pinsDRUKS_SBX_HOME, creates the.drukboxbind source with the correct owner, and stops with instructions when the sandboxd socket is missing..env.Verified
All three shapes rendered with
docker compose config; the guards fail loudly (missingDRUKS_SBX_HOME, missingSERVICE_TOKENS). The setup changes (always-rendered token, preserved keys) validated againstrun_setupdirectly, plus new tests.ruff checkandruff formatpass on the touched backend files. The full backend pytest suite needs a live Postgres and was not run in this environment.Comments and docs in this PR use simplified English (ASD-STE100).