From a model that fits on a napkin to a live, TLS-terminated, RBAC-backed web application, with one command.
This document explains everything about how Data UI deployment works: the big picture, the command, every moving part behind it, where the secrets live, how the cert renews itself at 3am while you sleep, and what to do on the rare day something goes sideways. It is written so that a junior programmer can follow along. If you can run a shell command and have seen a YAML file without crying, you are qualified.
deploy Actually Does, Step by StepMost deployment stories involve a wall of YAML you wrote by hand, a wiki page titled “DO NOT TOUCH unless you are Dave,” and a Dave who left the company in 2023. Data UI’s story is shorter: the model is the configuration.
Your model already declares the application’s identity:
(:title "To Do List"
:name "todos"
:version "0.1"
:domain "todo.demo.data-ui.com"
:repl t
:types ...)
The deploy pipeline reads those five keys and derives everything from them: the Docker image tag, the Kubernetes namespace, the release directory, the HAProxy backend, the public URL. There is no separate deployment config to drift out of sync with the application, because there is no separate deployment config.
The target environment is deliberately modest: a single machine (the “deploy host”) running a k3d cluster (k3s in Docker), with HAProxy in front terminating TLS. No cloud bill, no managed Kubernetes, no Helm charts. One box, one command. There are now two production sites on that shape — evo-x2 at home and prod-2 on EC2 (see Two Production Sites) — but each site is still one box, and staging, demos, and Model Bank live only on evo-x2.
There are exactly three source checkouts, and only the first is ever dirty:
~/common-lisp/data-ui, wherever you are hacking. It may be dirty, detached, or on a feature branch; none of that ever reaches production, because no production build reads it./data/data-ui/repos/staging. Host profiles (dataui@* units) load their Lisp, models, and scripts/data-ui from here. It is updated only by scripts/data-ui staging update (default private/master), which also builds its frontend and installs the host ops files./data/data-ui/repos/production. Every deploy and delete runs this checkout’s script, after fetching and fast-forwarding it to public/master (or to --from REMOTE/BRANCH). Canonical remotes: public = git@github.com:macnod/data-ui.git, private = git@github.com:macnod/data-ui-private.git.Neither deployment clone lives beneath ~/common-lisp (ASDF’s default source-registry search tree), and neither is a worktree, a copy of a .git, or a second .asd — each is a real clone. /data/data-ui otherwise holds runtime state (profiles, databases, uploaded files, snapshots, credentials, exposure configuration, deploy state); the only source code under it is these two clones. Selection keeps one local branch per upstream (deploy/REMOTE/BRANCH), so switching sources switches branches and never resets one branch across unrelated histories.
deploy MODEL therefore always means: fetch and fast-forward a clean production clone to the selected revision, print the source and the full SHA, then re-execute the production script there for the actual build. DRY_RUN=1 changes none of that (see Dry Runs).
On the deploy host (or any machine with ssh access to it; see Deploying From Another Machine):
cd data-ui
scripts/data-ui deploy todos
That’s it. The output ends with:
Deployed To Do List todos-0.1-6d8f586.
Source: public/master @ <full SHA>
Domain: https://todo.demo.data-ui.com
NodePort: http://172.18.0.2:30303
Swank: kubectl -n dataui-todos port-forward deploy/dataui-todos 4005:4005
Open the domain, log in as admin with the password from Secrets, and you are looking at your deployed application. If you’ve been developing against the dev REPL and want the app with its data in production, see First deploy of an app you’ve been developing below.
Requirements:
$DEPLOY_CHECKOUT — the deploy fast-forwards it to the selected revision and refuses to touch a dirty tree (your development checkout is never inspected, cleaned, or pushed). deploy-bootstrap creates the clone on a fresh host.sudo access on the deploy host (for the HAProxy update, nothing else).The one command above assumes the code is already at public/master and an empty database is fine. When you’ve been developing against the dev REPL and want the app with its data in production, the code should already be committed and pushed to private/master (your normal development flow), and then:
scripts/publish-data-ui --prefer-private "SceneBook v0.6: …" # code reaches public/master
scripts/data-ui deploy scenebook
scripts/data-ui snapshot restore dev-scenebook prd:scenebook # dev data travels over
scripts/data-ui snapshot save prd-scenebook prd:scenebook # optional known-good marker
deploy builds the production clone at public/master: committed but unpublished work never ships (publish first, or deploy --from private/master)admin-password (restore re-stamps the destination’s own — see Secrets)$DEPLOY_CHECKOUT)deploy never builds the checkout you are standing in. It builds the production clone at /data/data-ui/repos/production — a clean, independent git clone (remotes public and private), created by deploy-bootstrap on a fresh host. The path defaults in scripts/lib/checkout.sh and can be overridden per-invocation:
DEPLOY_CHECKOUT=/some/other/clone scripts/data-ui deploy todos
The deploy fetches that clone, fast-forwards it to public/master (or exactly --from REMOTE/BRANCH), refuses a dirty tree, and re-executes the clone’s own scripts/data-ui there for the actual build. Full story: Source Environments.
The Model Bank Deploy button is the same pipeline with one difference: the model. The button’s action hook (:deploy-model) shells out to scripts/data-ui deploy — the production clone is selected, fast-forwarded, and built exactly as above — but the model the user typed into the form is handed over as MODEL_FILE (a unique file under models/local/deploy-incoming/). The engine still comes entirely from the selected revision; the typed model rides into the build context as models/local/<name>.lisp and is never committed — it is promoted to a stable copy in the production clone only after the deploy’s health gates (see VIP Deploys).
scripts/data-ui deploy todos # update to the latest public/master
scripts/data-ui deploy todos --from private/master
scripts/data-ui delete todos # take down the app (asks; FORCE=1 skips)
Update is the same command as the first deploy: publish the new code (scripts/publish-data-ui), run deploy again, and the clone is fast-forwarded, a new image is built and rolled out, and the instance keeps its database and uploaded files. A bad release is fixed by a revert commit on the upstream followed by another deploy — never by selecting an old tag (see Selection, Locks, and Rollback). delete first saves a farewell snapshot of the instance’s last state (prd-todos-last in the snapshot pool), then removes the Kubernetes namespace and volumes, the host-side application data, the HAProxy route, and the deploy state and secrets.
A demo is not a Docker deploy but a host profile: a dataui@<profile> systemd unit running SBCL directly on the deploy host, loading code from the staging checkout (/data/data-ui/repos/staging), with its own PostgreSQL and uploaded files. All demos share the one engine checkout; the only per-demo things are profile.env, the database, and files/. The model must be committed and pushed to private (staging’s default source — publish-data-ui is not needed) and delivered by staging update before profile create can see it; a local-only model is delivered instead by profile install-model <model> from the development checkout. Two classes share the same machinery: e-demos, whose data is disposable and reset nightly, and persistent demos, which keep their data. Verb reference: docs/cli.md → e-demo / demo; host machinery: ops/README.md; snapshot slots: docs/snapshots.md; user-facing walkthroughs of the live apps: docs/demos.md.
Ephemeral: every morning at 04:10 the nightly reset restores the profile’s stg-<profile>-golden snapshot, wiping the day’s accounts, junk rows, and uploads. Until a golden exists the reset skips the profile (bootstrap window) — so take the golden right after seeding the demo content.
git push private master # the model must reach staging's source
scripts/data-ui staging update # fast-forward staging, restart running demos
scripts/data-ui profile create todos # ports + secrets (prints admin password)
scripts/data-ui e-demo start todos # start; enrolls in the nightly reset
# After you've added data
scripts/data-ui snapshot save stg-todos-golden stg:todos
# Makes it visible to the world at the host name specified by the model's
# :domain-stg key.
scripts/data-ui profile expose todos
Update is staging update again — it rebuilds the frontend and restarts every active demo on the new code, health-gated; demo data is untouched. Delete is e-demo stop todos (saves stg-todos-last first), then profile delete todos (asks; FORCE=1 skips).
Same verbs with demo in place of e-demo, same machinery — the only difference is class: no nightly reset, and the golden stays a manual safety copy. demo reset <profile> restores the golden on demand. Model Bank is the persistent-class example.
deploy Actually Does, Step by Stepscripts/data-ui deploy runs the following phases, in order. Each phase is a shell function in scripts/data-ui, so the script is the authoritative reference; this is the guided tour. (Phase 0, before all of these: the outer arm selects the production checkout and re-executes its script — see Source Environments; what follows is the inner, production-side body.)
Immediately before the compile gate (and only when the compile runs — a registry hit or a recorded release skips this along with the compile), the deploy fast-forwards the Roswell local-projects clones under ~/.roswell/local-projects/macnod/ — the second source stratum, which the host-side compile resolves :rbac, :p-log, and the other macnod libraries through on a host without a ~/common-lisp dev tree (prod-2; on evo-x2 the dev tree masks the clones, and the refresh is hygiene). The repo list is parsed from the checkout Dockerfile’s ros install lines, in file order. Per repo:
refs/heads/master into the explicit remote-tracking ref, then merge --ff-only onto master — one macnod/<repo>: <old> -> <new> movement line when HEAD moves, silence when the clone is currentmaster first, via git switch --guessros install macnod/<repo> in file ordercompile_model
Before anything ships, the model in models/<model-name>.lisp must compile. The script starts a throwaway PostgreSQL container (its own container name and port 5446, so it never collides with your dev REPL database on 5444 or the test database on 5445), initializes the schema, and runs the compilation phase of set-model (validation, SQL generation, lambda compilation) against it. Then the container and its volume are destroyed.
If the model doesn’t compile, the deploy dies right here, before a tag, an image, or a manifest exists. A broken model never gets anywhere near the cluster.
gather_deploy_facts
The script asks the model for its :name, :title, :version, :domain, and :repl values (via a tiny Lisp helper, lisp/deployment.lisp). From those plus the git short hash, it derives:
| Fact | Example |
|---|---|
| TAG | todos-0.1-6d8f586 |
| IMAGE | macnod/data-ui:todos-0.1-6d8f586 |
| NAMESPACE | dataui-todos |
| RELEASE_NAME | To Do List todos-0.1-6d8f586 |
| OUT_DIR | /data/data-ui/deploy/todos/releases/0.1-6d8f586 |
create_deploy_tag
An annotated git tag (todos-0.1-6d8f586) is created at HEAD. If the tag already exists and points at HEAD, it is reused (re-deploying the same commit is fine). If it exists and points elsewhere, the deploy aborts: a tag must never silently change meaning.
assign_node_port
Each instance gets a stable NodePort (starting at 30303; 30300–30302 are reserved for k3d’s published loopback hops). The assignment is cached in /data/data-ui/deploy/ports.lock, but the cache is not the source of truth; the cluster is. If the lock file is missing, the port is recovered from the live Service. Only when neither exists is a new port assigned (lowest free port ≥ 30303, checked against both the lock file and every NodePort in the cluster).
ensure_instance_secrets
See Secrets. Same cache-vs-truth design: file missing → recover from the live Kubernetes Secret; no live Secret either → generate fresh credentials. Credentials are never regenerated for an existing instance, because the PostgreSQL volume keeps the old password and new credentials would lock the app out of its own database.
generate_manifests
The templates in deploy/templates/*.yaml.tpl are rendered with plain sed substitution of ``: no templating engine, no dependencies, nothing to install. Two special cases:
#@repl survive (marker stripped) only when the model says :repl t; otherwise they are deleted. This is how the Swank port appears in the manifest for REPL-enabled instances and doesn’t exist at all for production ones.tests/init-template.sql and wrapped into a ConfigMap with kubectl create configmap --dry-run.Rendered manifests land in the release directory (OUT_DIR above), so every release’s exact manifests are preserved for inspection or rollback.
build_image
A multi-stage Docker build:
npm ci && npm run build, the React frontend, typechecked and bundled by Vite into static files.--disable-debugger so any unhandled error prints a backtrace and exits instead of waiting politely at a debugger prompt inside a container nobody is attached to.The image is then imported into the k3d cluster with k3d image import, so nothing leaves the machine. On evo-x2 (no IMAGE_REGISTRY) that is the whole story and no registry is involved. On prod-2 the registry path wraps the same steps: before the compile, a probe pulls the content-addressed image from ECR (data-ui/<app>:deploy-<arch>-<git sha>-<model sha256>) — a hit skips the compile and the build (only the k3d import runs); a miss builds exactly as above and pushes the image back as a best-effort cache fill (a push failure warns, never fails the deploy; REBUILD=1 force-builds and re-pushes over the same tag).
apply_manifests
kubectl apply -f $OUT_DIR, then wait for the PostgreSQL rollout, then the app rollout. First boot initializes the database (RBAC tables, roles, permissions, admin/guest users), which is why the app’s startupProbe allows up to five minutes before the liveness probe is allowed to have opinions.
update_haproxy
The only step that needs sudo. Details in How HAProxy Routing Works.
Worth repeating with the actual flow drawn out:
models/<model-name>.lisp
:name "todos" ──────────┬─→ namespace dataui-todos
:version "0.1" ────────┼─→ tag todos-0.1-<git-hash>
:domain "todo.demo..." ┼─→ HAProxy map entry + backend
:repl t ───────────────┴─→ Swank port in the manifest (or not)
Change :domain in the model and redeploy: the new domain routes to the app. Bump :version: new tag, new release directory. Set :repl nil: the Swank listener vanishes from the deployment. The model is not input to the configuration; it is the configuration.
(Note the TODO in the example model: :repl should be nil in production. The Swank port is never exposed through a Service either way; it is reachable only via kubectl port-forward, which requires cluster credentials.)
An environment is where a running instance lives. There are three: development, staging, and production. The word “mode” and ad-hoc “local”/”deployed” phrasing are retired in favor of these.
The environment is a property of the launch path, never stored in the model:
scripts/data-ui repl (no profile) → development (throwaway 5444 database: the container and its volume are removed when the REPL exits, so the schema always matches the code just loaded)scripts/data-ui repl <profile> / e-demo start <profile> / demo start <profile> → staging (profiles run under systemd units via the e-demo / demo verbs); profile expose is a visibility toggle, not part of the definitionscripts/data-ui deploy <model> → production (also the Deploy button, once production supports it — post-MVP)One model may run in all three environments simultaneously, and each instance has its own database by construction:
dataui in pg-data-ui-repl (port 5444)pg_ident(<profile>) in pg-data-ui-<profile> (its own compose project)dataui-<name> with its own postgresConvention: one instance per model per environment; a second copy in the same environment is a new model. Data: development is volatile (snapshots only); staging and production are persistent — staging is not disposable. The admin password is static in development (admin / admin-password-1, by convention — see docs/snapshots.md) and generated per instance in staging (profile.env) and production (cluster secrets). Snapshot restore re-stamps the destination’s own admin password hash, so a restored database always answers to its environment’s password (see docs/snapshots.md → Password re-stamping). During the MVP, staging is the flagship environment: it hosts Model Bank and has the Deploy button, which production lacks. Staging does not mirror production’s substrate (host process vs k8s); passing staging is not a substrate guarantee. An environment is not a “tier”: tiers are product offerings; environments are where an instance runs.
PUBLIC_ORIGIN (public pages)The public pages (/p/, the sitemap, the feed) build every absolute URL — canonical, og:url, article:published_time, feed guid, Sitemap: line — from one configured origin, never from the request’s Host. It is an absolute http/https origin with no path, query, or fragment:
http://127.0.0.1:$HTTP_PORT (no variable needed)profile create writes PUBLIC_ORIGIN=http://127.0.0.1:<port> into profile.env; profile expose rewrites it to https://<domain> and profile unexpose restores the loopback spelling, each printing that the profile must be restarted so the image re-reads it. load_profile treats the key as required — existing profiles must add the line (a missing origin is how a staging unfurl ships a loopback canonical)PUBLIC_ORIGIN=https:// in the pod envA bad value is a 500 on /p/ (the log names PUBLIC_ORIGIN); the authenticated API keeps working. Public pages are rendered on request and need no rebuild after a snapshot restore.
:domain-stgThe model’s :domain remains the canonical production FQDN, used by deploy. Staging exposure (profile expose) reads :domain-stg; when the author omits it, the compiler derives it by suffixing -stg onto the first DNS label of :domain (todo.demo.data-ui.com → todo-stg.demo.data-ui.com). An explicit :domain-stg always wins; it must differ from :domain (one HAProxy map line, one owner) and requires :domain when written. The deploy-button exception is modelbank: staging keeps the clean canonical URL (modelbank.demo.data-ui.com) and production takes the -p suffix — both explicit. -stg hosts and modelbank’s two names all live under the existing *.demo.data-ui.com wildcard (DNS + TLS), so no new zone or certificate is involved.
Every real :generate-model LLM call (the Generate button on Model Bank) writes its full prompt — system message, user message, LLM model, temperature, record name, timestamp — as one org-mode file to the shared host directory /data/k8s/data-ui/generate-log/, named <app-name>-<record-name>-<timestamp>.org. Format: one level-1 org heading per field (the former JSON keys); the * system-prompt heading carries two level-2 children mirroring the prompt’s two parts — ** Model Syntax Reference (docs/model-reference.md verbatim in a #+begin_src markdown block) and ** Examples (the framing prose, then every demo in one #+begin_src lisp block). Both blocks are org-comma-escaped so a C-c ' edit round-trips; in the JSON body the two parts ride one system string, with part 2 opening under a # Examples markdown heading. (2026-09-27: the prompt’s NUL pollution — a u:slurp UTF-8 bug that sent ~233 literal NULs to the LLM — was fixed at the source in dc-eclectic.) Unconditional and best-effort: a logging failure (missing dir, full disk) is logged and never fails Generate; test runs using the LLM override write nothing. The API key is a header and never rides the logged body. The directory is host-level today (every host instance runs as the same user); /data/k8s/ placement means extending it to deployed production apps later is a pure ops change — mount a hostPath PV at the same path into app pods, zero code delta. The instance cannot yet name its environment (a backlog item), so dev and staging generations are distinguished only by app + record name.
Deployment state lives outside the repository, in /data/data-ui/deploy/ on the deploy host:
/data/data-ui/deploy/
├── ports.lock # name env port, one per line
└── todos/
├── secrets.env # instance credentials (0600)
└── releases/
├── 0.1-c13571a/ # every release's manifests, kept
└── 0.1-6d8f586/
├── 00-namespace.yaml
├── 05-secrets.yaml
├── 10-pv.yaml
├── 15-pvc.yaml
├── 20-init-sql.yaml
├── 30-postgres.yaml
├── 40-data-ui.yaml
├── haproxy-backend.cfg
└── haproxy-map-entry
Why outside the repo? Because rendered manifests are derived output (rebuildable from model + templates + state) and secrets are, well, secret. The repo holds source; the state directory holds facts about one particular machine’s cluster. Deleting the whole state directory is recoverable: ports and secrets are re-read from the live cluster on the next deploy.
Application data lives in a third place: the k3d cluster binds /data/k8s (host, on the SSD) into the node at the same path, and each instance’s PersistentVolumes use /data/k8s/data-ui/<name>-<env>/{db,files}. So even k3d cluster delete cannot destroy application data; it survives on the host filesystem.
Three layers, three lifetimes:
| Layer | Lives | Survives |
|---|---|---|
| Source (model, templates) | git repo | everything |
| Deploy state (secrets, ports) | /data/data-ui/deploy |
cluster recreation |
| App data (database, files) | /data/k8s/data-ui |
cluster deletion |
Each instance has exactly three secrets, generated once at first deploy:
DB_PASSWORD: PostgreSQL password for the dataui userADMIN_PASSWORD: the application’s admin loginJWT_SECRET: signs the API’s access and refresh tokensThe easy way (on the deploy host):
grep ADMIN_PASSWORD /data/data-ui/deploy/todos/secrets.env
The canonical way (works even if the secrets file is gone, from any machine with cluster access):
kubectl get secret -n dataui-todos dataui-todos-secrets \
-o jsonpath='{.data.admin-password}' | base64 -d; echo
Both should agree. If they don’t, trust the cluster: the file is a cache; the Secret is the truth. (This is a recurring design theme. When a cache and the cluster disagree, the cluster wins, the same way the dictionary wins at Scrabble.)
A war story, so you don’t repeat it: the very first end-to-end deploy “failed” with a wall of 401s. Backend verified healthy, JWTs verified valid, much head-scratching: the operator was logging in with the old admin password from a previous instance’s secrets. If your freshly deployed app rejects you, read the password again, slowly.
The snapshot machinery (dev + staging profiles, and production via prd: addresses) re-stamps the destination’s own admin password hash after every restore, so the env and the database never disagree. For a prd:<name> destination the working password after a restore is the cluster Secret’s admin-password — restore reads it live from the Secret (never the secrets.env cache) and re-stamps with exactly that value. See snapshots.md → Production for the full prd: story (deploy-host-only, scale-to-0 restore, prerestore slot, the EXIT trap’s failure modes).
ADMIN_PASSWORD is generated as $(openssl rand -hex 8)-a1. The -a1 suffix is not decoration: the rbac library’s password policy requires at least one letter, one digit, and one punctuation character, and sixteen random hex characters can satisfy the first two but never the third. The suffix guarantees all three, and the sixteen random hex chars provide the entropy. Yes, this was learned the hard way. No, the instance that taught us is no longer with us.
There is no rotation tooling yet. If you must rotate manually: update the Kubernetes Secret, update secrets.env, restart the deployment, and for DB_PASSWORD also ALTER USER dataui PASSWORD ... inside postgres (in that order of caution). For a demo instance, the clean-slate procedure below is honestly less error-prone.
The snapshot pool lives on the same SSD as the databases it protects, which makes it a convenience, not a disaster recovery plan. Two production instances have data that must survive the machine: SceneBook (the first paying customer’s continuity data) and the Backlog app (the project’s own memory). For those, host-side timers upload fresh snapshots off the machine entirely — into a private, versioned S3 bucket. The pool can burn with the house; the S3 copy cannot. (Until November 2026 this role was filled by a Google-Drive folder synced by Insync — but the folder lived on the same host’s /data, so a dead host took its only off-site copy with it, the 2026-11-18 outage class. The Drive folders remain as a read-only legacy archive; nothing new depends on them.)
The target is one bucket, data-ui-backups-232168665831 (us-east-1, private, public-access-blocked, SSE-S3, versioned). Retention is lifecycle rules, never scripts — deletion is S3’s job, and the backup credentials cannot delete at all. The key prefix carries the host and the tier:
Key prefix (s3://<bucket>/…) |
Contents | Expires |
|---|---|---|
evo-x2/backlog/hourly/ |
full triple per hour | 1 day |
evo-x2/backlog/daily/ |
server-side copy of one hourly triple | 30 days |
evo-x2/scenebook/rpo/ |
.dump + .meta per 30 min |
1 day |
evo-x2/scenebook/daily/ |
full triple incl. photos tar | 30 days |
evo-x2/backlog/model/, evo-x2/scenebook/model/ |
the model file | never (noncurrent after 90 d) |
prod-2/<app>/… |
the same tiers, written by prod-2’s timers | same (the lifecycle rules are cloned onto prod-2/) |
prod-2/site/… |
release records + the per-site manifest | 90 d noncurrent |
The site prefix is parameterized (BACKUP_SITE, default the site marker, else evo-x2): prod-2’s timers write prod-2/, evo-x2’s stay evo-x2/. RESTORE_SITE (default BACKUP_SITE) retargets restore/recover reads — the move runbook stages evo-x2’s set onto prod-2 with RESTORE_SITE=evo-x2, and the reverse (staging prod-2’s set on evo-x2, e.g. for a drill or a move back) is RESTORE_SITE=prod-2. On prod-2 the instance role carries the credentials (the env file holds only AWS_REGION and AWS_BUCKET); on evo-x2 the dataui-backup-evo-x2 IAM user remains.
Lifecycle filters are full key prefixes (evo-x2/ first) — a filter like backlog/hourly/ matches nothing under evo-x2/backlog/hourly/… and the rule never fires. Versioning is the backstop for the no-delete posture: every rule carries a NoncurrentVersionExpiration too (1 day for the data tiers, 90 days for the model prefixes), or the bucket would grow forever behind delete markers.
The machinery is not part of scripts/data-ui — it is host machinery, one script per app shipped in the repo under ops/ (ops/backlog-backup, ops/scenebook-backup) and run from ~/bin/<unit> as a symlink into the production clone’s copy, driven by user-level systemd timers (lingering is enabled for the user, so they run at boot with no login session). Each app installs five units: the base .service/.timer pair, a -daily.service/-daily.timer pair (OnCalendar=*-*-* 03:20:00, Persistent=true), and one shared -fail.service:
scenebook-backup — every 30 minutes (OnCalendar=*:0/30, persistent), saves prd-scenebook-<YYYYMMDD-HHMM> from prd:scenebook and uploads .dump + .meta only to scenebook/rpo/ (the RPO tier — the daily-only photos tar kills the tar-multiplication problem). The 03:20 daily saves a fresh full triple to scenebook/daily/ (there is no tar in the RPO tier to promote).backlog-backup — hourly, saves prd-backlog-<YYYYMMDD-HHMM> from prd:backlog and uploads the full triple to backlog/hourly/. The 03:20 daily promotes the newest hourly triple to backlog/daily/ with a server-side copy (S3-to-S3, no download, no egress).Each app’s daily cycle also syncs the model file into <prefix>/model/ (resolved in the production checkout with set-model’s shadow order: models/<name>.lisp first, else models/local/<name>.lisp). Snapshots do not carry the model, and VIP models live in gitignored models/local/ — the model rides the backup so a cold host never dies mid-crisis for lack of it. A missing model file fails the daily run loudly.
The scripts live in git under ops/ and reach the host through a symlink: ~/bin/<unit> → /data/data-ui/repos/production/ops/<unit>. The repo home gives them history, review, and a cold-host rebirth path (clone the repo, re-link, start); the stable ~/bin name keeps the public verbs, the PATH, and the units’ ExecStart unchanged. A symlink into a local clone carries none of the old Drive-symlink hazard — that risk was the Insync daemon behind the link, not symlink-ness. The coupling to accept: backup-machinery changes ride the normal deploy train, so a routine deploy pull updates the running scripts (each change lands reviewed and versioned, where untracked real files in ~/bin had neither).
One base cycle: snapshot save the timestamped triple via the production clone’s scripts/data-ui (downtime-free), verify all three files, upload .meta (+ .files.tar.gz where the tier holds it) then .dump last, head-verify each object’s size, then rm the pool triple and prune the pool. S3 objects are atomic — there is no half-written-file hazard. The prune matches only names whose suffix parses as YYYYMMDD-HHMM (the name is the save time; mtimes are never consulted), so word-named snapshots (-final, keep-* copies) and the machinery’s own slots (-last, -prerestore, the bare prd-<name>) are immune; the S3 side is never pruned by a script — lifecycle owns remote retention.
The aws CLI is stateless (no agent, no local sync state; the script is the sync) and lives in /snap/bin — the scripts put a PATH that includes it after the inherited one, because systemd user units would not find it otherwise. Credentials live in ~/.config/data-ui-backup.env (mode 600, not synced): on evo-x2 AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_BUCKET — the dataui-backup-evo-x2 IAM user, scoped to the evo-x2/ prefix of this bucket for writes and reads (PutObject/GetObject + the five multipart actions, ListBucket conditioned to the prefix), plus read-only on prod-2/* (GetObject, and ListBucket conditioned to that prefix) so a reverse move or cross-site drill can stage prod-2’s sets on evo-x2. No DeleteObject, no lifecycle or bucket admin — a buggy script cannot destroy history. On prod-2 the key pair is optional: the instance role carries the credentials (the env file there holds only region and bucket), scoped to prod-2/* with read on evo-x2/* for the moves.
If a cycle fails, the shared OnFailure fail unit pings Mattermost (the macnod-bot user, Water Bottle channel) naming the failed service, with the journal tail. Its credentials live in ~/.config/<unit>.env (mode 600, not synced); a missing or incomplete file degrades the ping to a stderr line — it never blocks a backup or a stop.
scenebook-backup status # timer states, last-run results, newest object per tier, model sync date
scenebook-backup run # one base cycle now (what the timer runs)
scenebook-backup run daily # the daily cycle (full save / promotion + model sync)
scenebook-backup restore # newest daily-tier backup -> snapshot pool
scenebook-backup restore prd-scenebook-daily-20261119-1000
scenebook-backup restore prd-scenebook-20261119-1000 rpo # a specific RPO-tier backup
scenebook-backup location # print the S3 backup prefix
scenebook-backup stop # disable both timers, remove the five units (S3 objects stay)
(backlog-backup takes the same verbs; its tiers are daily and hourly.) Restoring downloads the tier’s objects back into the snapshot pool, where snapshot list sees it; from there the normal snapshot restore machinery takes over. The pool is the interface — S3 is just another place triples live. The tier is the second argument or a --tier flag, never a bare snapshot-name slot. The printed follow-up command targets prd:<app> by default; RESTORE_PRINT_TARGET=<address> retargets it (drills and gates point it at a scratch profile) — it changes only the printed text, never where anything lands.
<unit>-backup recover # select the freshest COMPLETE set, download it, print the restore order
<unit>-backup recover --check # select + verify completeness without downloading (rebirth preflight)
recover never relies on key order across tiers: candidates group by exact basename per tier, sidecars complete a candidate only from the same tier, and the newest complete candidate wins — a newest candidate missing files.tar.gz falls back to the older complete triple. Backlog prefers the hourly tier when its newest complete triple is newer than the daily’s. SceneBook picks the newest complete daily triple, then applies the newest rpo dump+meta pair on top only when its timestamp is newer; the daily-files / rpo-database age gap is printed verbatim first (which files tree accompanies which database, and how far apart). The printed restore: <name> lines are the restore order — scripts/data-ui rebirth --fresh-data runs them itself.
Backlog runs on prod-2, so its freshest triple is in the prod-2/ prefix, not on evo-x2. recover stages into the snapshot pool of the host it runs on; it does not touch the live app, and S3 keeps its copy. Log into prod-2 and run:
~/bin/backlog-backup status
~/bin/backlog-backup recover
status is the look; recover is the pull. It prints the name it staged (a run on 2026-11-22 picked prd-backlog-20261122-2300, newer than that day’s daily). Back on evo-x2, copy that triple into the local pool — substitute the printed name:
scp prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.dump \
prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.files.tar.gz \
prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.meta \
/data/data-ui/snapshots/
Confirm it landed, then restore it into the local dev instance. Postgres has to be up first (scripts/data-ui db or repl):
scripts/data-ui snapshot list
scripts/data-ui snapshot restore prd-backlog-20261122-2300 dev:backlog
Do not restore to prd:backlog from evo-x2. That instance lives on prod-2, and a prd: restore scales the app to 0. A model mismatch is a hard refuse, not a warning.
Coverage is per app and explicit. A newly deployed production instance has no off-site backup until someone installs a timer for it (copy the script from ops/, change its per-app constants — PREFIX, APP_PROFILE, S3_APP_PREFIX, MODEL_NAME — and the unit name, symlink it into ~/bin, add the app’s tier prefixes and lifecycle rules, and run start); nothing in deploy creates one. If an app’s data matters, its backup timer is part of its definition of done.
Each instance is fully isolated in its own namespace, dataui-<name>. The manifests, in apply order:
| File | What it creates |
|---|---|
00-namespace.yaml |
The namespace dataui-<name> |
05-secrets.yaml |
dataui-<name>-secrets (the three credentials) |
10-pv.yaml |
Two hostPath PersistentVolumes: db (2Gi), files (5Gi) |
15-pvc.yaml |
The matching PersistentVolumeClaims |
20-init-sql.yaml |
ConfigMap with the schema init SQL |
30-postgres.yaml |
PostgreSQL 16 Deployment + postgres Service |
40-data-ui.yaml |
The app Deployment + NodePort Service |
Highlights of 40-data-ui.yaml:
users table doesn’t already exist, so restarts don’t re-run it.secretKeyRef, document root, the version tag.startupProbe gives first boot up to 5 minutes (database initialization happens then); after startup succeeds, a readinessProbe (every 5s) gates traffic and a livenessProbe (every 15s) restarts a hung container. All three hit GET /health./health script name runs one at a time per Lisp process, behind a gate in lisp/rest.lisp. /health deliberately stays outside it, so the probes above and the HAProxy option httpchk GET /health check in “How HAProxy Routing Works” keep answering while a real request holds the gate. A slow or stuck non-health request therefore queues the rest of the application without failing any health check: a passing /health reports liveness, not that the app is serving. Async workers and REPL activity are not covered. The backlog item Interim request serialization owns the temporary gate; Deadlock under concurrent requests owns the real fix and the gate’s removal.Recreate, because the files PVC is ReadWriteOnce: a rolling update would deadlock with old and new pods both claiming it.#@repl marker in the template and exist only for REPL-enabled models.HAProxy was already serving other domains on this host, so Data UI had to move in without rearranging the furniture. The design adds exactly one line to the existing config, once, and after that new instances never touch the main config at all.
Three pieces:
/etc/haproxy/data-ui.mapA plain text file mapping hostnames to backend names:
todo.demo.data-ui.com dataui-todos
parts.demo.data-ui.com dataui-parts # (a future instance)
use_backend %[req.hdr(host),lower,map(/etc/haproxy/data-ui.map)] \
if { req.hdr(host),lower,map(/etc/haproxy/data-ui.map) -m found }
In English: lowercase the Host header, look it up in the map; if found, route to that backend. One line handles every current and future Data UI instance. The deploy script inserts it (idempotently) just above the existing default_backend line.
/etc/haproxy/conf.d/dataui-<name>.cfgbackend dataui-todos
mode http
option forwardfor
option httpchk GET /health
server dataui-todos 172.18.0.2:30303 check inter 2000 rise 2 fall 3
That points at the k3d node’s IP and the instance’s NodePort, with an active health check against the same /health endpoint the Kubernetes probes use. (assign_backend_target is fail-closed on the k3d-published loopback hop 127.0.0.1:<NodePort+1000> — e.g. 127.0.0.1:31303 — since 2026-09-30: if the hop does not answer, the deploy dies rather than render a bridge-IP target that goes stale when docker reassigns node IPs.) The conf.d directory is enabled via EXTRAOPTS in /etc/default/haproxy (also a one-time, idempotent step).
On every deploy, the script: installs/updates the backend file, upserts the map entry, validates the whole config (haproxy -c across the main file and conf.d), and only then reloads. If validation fails, nothing is reloaded and the old routing keeps working.
Locally-run host profiles (scripts/data-ui profile expose) use the same machinery with a different backend name: dataui-profile-<name> points at 127.0.0.1:<HTTP_PORT> on the host instead of a k3d NodePort (the model :name values profile and profile-* are reserved so the two can never collide). One domain, one backend: profile expose refuses a map line owned by a deployed instance, and a deploy refuses a map line owned by a profile exposure — neither stops the other side’s pods; delete (undeploy) first, then profile expose. profile unexpose (and profile delete) remove the exposure.
One subtlety, learned in production (where else): systemctl reload haproxy re-execs the master process with its original command line. If EXTRAOPTS was just modified to add -f /etc/haproxy/conf.d, a reload will not pick that up: the running master has never heard of conf.d, and your shiny new backend 503s while the NodePort works perfectly. The script handles this: the deploy that first enables conf.d does a full systemctl restart; every subsequent deploy does the gentler reload.
demo404)Hosts under *.demo.data-ui.com that the map does not know about (typos, retired demos) used to be redirected to data-ui.com — a 301 browsers cache forever, which stranded visitors after a rename. They now get a real 404 page that names the requested host and lists the demos that are running. The bare apex, demo.data-ui.com, serves the same list as a normal 200 page — the directory.
HAProxy has no CGI, so the page comes from a tiny local service, demo-directory.service: a stdlib-only Python HTTP server on 127.0.0.1:8484 (hardened: DynamicUser, ProtectSystem=strict), wired in as the host-owned demo404 backend (ops/demo404.cfg; no dataui- prefix, so the profile/deploy tooling never touches it). Two use_backend demo404 rules in the https frontend cover the apex and the unmapped-host fallthrough; everything routed by the map is unaffected.
The list can never go stale: the service re-reads /etc/haproxy/data-ui.map on every request, so profile expose / unexpose and deploys are reflected instantly, with no restart. Hosts listed in the EXCLUDE set at the top of the script (currently chat, which is infrastructure, not a demo) stay routed but are never listed.
It survives reboots on both sides: the unit is enabled (a Wants symlink into multi-user.target) with Restart=on-failure, and HAProxy loads conf.d — and with it demo404.cfg — at boot via the EXTRAOPTS line in /etc/default/haproxy. If the service is down anyway, unmapped hosts get a plain HAProxy 503 (backend down); mapped demos keep working.
Sources live in ops/ (demo-directory.py, demo-directory.service, demo404.cfg); the installed copies are targets, never edited in place. Everything is managed by the demo-directory CLI (source: ops/demo-directory, installed to /usr/local/bin/demo-directory; checkout override via DATA_UI_CHECKOUT):
# one-time: install the CLI itself, then everything else
sudo install -m 755 ops/demo-directory \
/usr/local/bin/demo-directory
demo-directory install # script + unit + HAProxy backend,
# enable --now, validate, reload
demo-directory status # enabled/active/health/demo list
demo-directory start|stop
There are two copies of the script: the source (ops/demo-directory.py in the repo) and the installed target (/opt/demo-directory/demo-directory.py, the one systemd runs). Edit the repo copy, then push it live with one command:
demo-directory update
It syntax-checks the script (refusing to install a broken file), installs it over the target, restarts the service (Python loaded the old code at startup), and health-checks the result. Never edit /opt directly — the next update would silently overwrite it.
Verification: the 404 page is served no-store, so a bogus host shows changes instantly (curl -s https://no-such-demo.demo.data-ui.com/); the 200 directory page at the apex caches in a browser for 60s. If the service refuses to come up, systemctl status demo-directory / journalctl -u demo-directory show the startup line.
All demo instances live under *.demo.data-ui.com, so a single wildcard certificate covers every app, present and future. Adding a new instance requires zero TLS work. That is the entire point.
*.demo.data-ui.com points at the deploy host’s public IP (Route 53). A small cron-driven script (update-dns) re-upserts the record if the host’s IP changes, because residential ISPs consider a stable IP a premium feature.certbot-evo-x2, can do nothing else. Least privilege isn’t paranoia; it’s just manners.):443 bind has crt /etc/haproxy/certs/, a directory. HAProxy loads every pem in it and uses SNI to pick the right certificate per hostname. New cert for a new domain family? Drop a pem in the directory, reload. No bind-line surgery.deploy/setup-tls.sh does the whole dance idempotently: installs the IAM credentials for root (renewals run as root), installs the renewal hook, runs certbot certonly --dns-route53 for demo.data-ui.com + *.demo.data-ui.com, builds the combined pem, patches the bind line, validates, reloads. Run it once per deploy host and forget it.
Note the wildcard covers anything.demo.data-ui.com but not the bare demo.data-ui.com; that’s why the cert requests both names.
The certbot.timer systemd unit fires twice a day. When the cert is within 30 days of expiry, certbot renews it via DNS-01 and then runs the deploy hook installed at /etc/letsencrypt/renewal-hooks/deploy/haproxy-pem.sh (source: deploy/letsencrypt-haproxy-hook.sh), which:
fullchain.pem + privkey.pem into /etc/haproxy/certs/demo.data-ui.com.pem (HAProxy wants one file; written atomically via a .new + mv, mode 600),To rehearse the whole thing without touching the real certificate:
sudo certbot renew --dry-run
If that passes, future-you has nothing to do, ever. Past-you already did it.
Deploys are triggered two ways: from a shell (interactive, you are present) and by the Deploy button on Model Bank, which runs the deploy script from inside the app’s process — a headless systemd context with nobody watching. The second way must never depend on a human answering a prompt. One of the two prompt traps was fixed with the NOPASSWD sudoers rule for HAProxy; the other is Docker’s credential helper, and it bites quietly:
~/.docker/config.json says "credsStore": "pass", so every registry operation — including the anonymous-looking pulls of node:22-slim and ubuntu inside docker build — consults docker-credential-pass, which decrypts ~/.password-store with the user’s GPG key. If gpg-agent’s cache is cold, gpg pops a pinentry dialog on the host desktop and waits. Nobody answers (it’s a guest’s deploy; the dialog isn’t even on their screen), the helper times out or gets a wrong passphrase, and the build dies with:
getting credentials - err: exit status 1, out: `exit status 2:
gpg: public key decryption failed: Bad passphrase
gpg: decryption failed: Bad passphrase`
ERROR: Docker build failed.
A wrong passphrase in that dialog — typed in haste at the desktop — produces exactly this. A correct one only buys you gpg-agent’s cache TTL; the next guest, hours later, hangs again.
The password store now encrypts to a dedicated passphrase-less GPG key. Decryption never prompts, so credential lookups work in any context — cold boot, systemd, ssh, cron. The tradeoff: the store’s contents are readable by anyone who can read ~/.password-store (file permissions, not cryptography, protect them). That’s acceptable here because the store holds nothing but the Docker Hub token; the protecting passphrase was guarding nearly nothing, while the prompt was breaking guest deploys entirely.
What was done:
# dedicated no-passphrase key (encryption subkey, never expires)
gpg --batch --passphrase '' --quick-generate-key \
"data-ui-docker-creds (pass store, no passphrase)" default default never
FPR=$(gpg --list-secret-keys --with-colons "data-ui-docker-creds" \
| awk -F: '/^fpr:/ {print $10; exit}')
gpg --batch --passphrase '' --quick-add-key "$FPR" default encr never
# two stale artifacts of an old docker login (index.docker.io/v1/
# access-token and refresh-token subpaths) — the helper only needs
# the plain index.docker.io/v1/ entry
pass rm -f 'docker-credential-helpers/<b64>/macnod' # x2, the stale ones
# re-encrypt the store (prompts once for the old key's passphrase)
pass init "$FPR"
If the one-time pinentry times out during pass init (nobody at the keyboard), just re-run it — the .gpg-id is already updated and each retry re-encrypts what remains.
# must print JSON, no dialog, no delay — even right after
# gpgconf --kill gpg-agent (i.e. with nothing cached)
gpgconf --kill gpg-agent
echo "https://index.docker.io/v1/" | docker-credential-pass get
That kills gpg-agent first on purpose: a warm cache can mask a broken setup, which is exactly how the first button deploys passed and a later guest deploy failed.
docker login on this host stores the token into the pass store under the same no-passphrase key — nothing to redo after a re-login.~/.docker/config.json, not this one; every host that runs button deploys needs the same treatment (or a bare config with no credsStore at all, which is the anonymous-pull alternative and works fine for public images).You don’t have to be on the deploy host. If hostname doesn’t match $DEPLOY_HOST (default evo-x2), the script becomes a thin forwarder — nothing more:
MODEL_FILE, transfers it non-interactively to a fresh mode-700 host temp directory outside both checkouts, and verifies type, size, and hash there (a host-side trap cleans the temp directory; cleanup after a network partition is best-effort),-t, so sudo and delete confirmations can prompt) and runs a host-side launcher: /data/data-ui/repos/production/scripts/data-ui if it exists and is executable, otherwise $DEPLOY_BOOTSTRAP_CHECKOUT/scripts/data-ui. A missing launcher fails before any mutation.The caller never selects a local production clone, never inspects or clean-checks its own repo, and never derives a SHA, writes facts or tags, pushes, or queries origin — including under DRY_RUN=1. The host-side outer deploy then does everything a local invocation does. After first bootstrap, the bootstrap checkout is never consulted; its dirt and branch are never inspected.
The whole remote command travels as one bash -c <quoted> argument through exactly one reparse, and only an environment allowlist is forwarded (DRY_RUN, FORCE, checkout/state/source overrides, cluster configuration) — never secrets on a command line.
Staging and production must name the same host (STAGING_HOST == DEPLOY_HOST; a differing pair is rejected before any lockfile, Git, npm, SSH, or systemd mutation). This is load-bearing, not a simplification: get-deployed-admin-password is a plain local read of $DATA_UI_STATE/deploy/<name>/secrets.env written by the deploy on the deploy host, so Model Bank’s deploy-model-record-secret works only on one machine; profile HAProxy operations are host-local too. Splitting the hosts (including remote secret retrieval) is a separate item.
The second production site does not split them: prod-2 is production-only (staging, demo, e-demo, and profile verbs are refused there outright), so STAGING_HOST == DEPLOY_HOST == evo-x2 continues to hold for everything staging-shaped. See Two Production Sites.
Production runs on two sites, partitioned by app sensitivity. evo-x2 (the home machine) keeps staging, demos, Model Bank, the Deploy button, and the less-sensitive production apps. prod-2 (a single EC2 instance, t4g.xlarge, Ubuntu 26.04 arm64, us-east-1) hosts the sensitive apps — Backlog first, then SceneBook — so a power outage at home can no longer take the paying customer’s app dark. Every app instance is owned by exactly one site; there is no active/active (no transactions today). Moving an app is a one-way migration: snapshot-replicate → restore → swing DNS.
/data/data-ui/site (one line, ^[a-z][a-z0-9-]*$) is a host’s identity. With it, local_site decides deploy/delete/cutover locality and apply_site_defaults arms the site’s settings; without it the hostname decides and the behavior is exactly the old single-site one. The marker is never written by a verb: ops/prod-2-host.sh post-image writes prod-2’s, evo-x2’s is stamped by hand.:= defaults — the environment wins): prod-2 sets DEPLOY_HOST=prod-2, K3D_CLUSTER=prod-2, DATA_UI_PUBLIC_URL=https://github.com/macnod/data-ui.git (anonymous HTTPS — no GitHub credential on prod-2), IMAGE_REGISTRY=232168665831.dkr.ecr.us-east-1.amazonaws.com, SITE_DNS_MODE=explicit, SITE_DNS_ZONE_ID=Z0152779JVWMFEK6RAKU, SITE_STATE_URI=s3://data-ui-backups-232168665831/prod-2/site, SITE_PRODUCTION_ONLY=1. evo-x2 (stamped) sets SITE_WILDCARD_ZONE=demo.data-ui.com. Deploys run over SSH from anywhere via the existing thin forwarder: DEPLOY_HOST=prod-2 scripts/data-ui deploy <app>.REBUILD and MOVE are forwarded.staging, demo, e-demo, and profile verbs (and every staging-routable shape: stg: snapshot addresses, named repl/db/psql) die at the public boundary with “this site is production-only” — before any routing, mutation, or stub call. profile install-model is exempt (it never routes).REBUILD=1 → login, build, push over the same content tag. The registry is a cache for deploys and the fast path for a rebirth — never a deploy gate.<app>.demo.data-ui.com; per-app A records (TTL 300) shadow the wildcard, and the wildcard itself is never touched. deploy never touches DNS there — scripts/data-ui cutover <model> publishes: pinned health → A record UPSERT (ops/prod-2-dns.sh) → INSYNC → pinned health again → the manifest row last, so the record only ever asserts a verified publication. Idempotent; a half-finished cutover is detectable (deploy’s closing summary reads the live A record via an exact type-A lookup and prints published / published but unrecorded — run cutover to converge / unpublished / publication unknown). delete removes the A record only when it holds this site’s address, using every domain the manifest rows and release.json name together.deploy backlog on evo-x2 after the moves would build a zombie there and report success — the home router answers every name in the zone with evo-x2’s LAN address, so the public-domain gate always tests evo-x2 itself. The guard asks a public resolver (dig @1.1.1.1) whether the domain’s public answer differs from the wildcard’s; when it does, the deploy dies with the corrected command (DEPLOY_HOST=<site> scripts/data-ui deploy <name>). MOVE=1 overrides and pins gate 2 to loopback.--resolve <domain>:443:<public ip>), proving this host, its certificate, and its security group during a move, in steady state, and on a temporary IP during a rebirth. SITE_HEALTH_IP=127.0.0.1 pins past a hairpin failure.TLS_AWS_AUTH=instance-role deploy/setup-tls.sh — no IAM user, no credentials file; the instance role may change only _acme-challenge.demo.data-ui.com TXT). The lineage lives on /data (/etc/letsencrypt → /data/letsencrypt), so an adopted volume needs no issuance. Do not loop fresh-lane drills: Let’s Encrypt allows five certificates per exact name set per week, shared with evo-x2’s renewals.release.json (image reference, full SHA, model hash, source, and the render facts) to deploy state and ${SITE_STATE_URI}/releases/<app>.json; cutover upserts and delete removes rows in the per-site manifest ($DATA_UI_STATE/ops/prod-manifest.jsonl, mirrored to ${SITE_STATE_URI}/prod-manifest.jsonl; rows keyed by model + site + domain). The manifest is the rebirth’s inventory — S3 backup prefixes never resurrect an app. A missing local manifest is re-materialized from S3 on read.ops/prod-2-aws.sh replace --adopt-data → post-image adopt → scripts/data-ui rebirth --adopt-data → verify → publish-eip; 2. snapshot (RPO ≤ 1 h): replace --from-snapshot; 3. S3 (database ≤ 30 min / 1 h; SceneBook photos ≤ 24 h): replace --fresh-data → rebirth --fresh-data. In every lane the old instance is fenced (stopped and retagged; a shutting-down straggler is waited out; more than one live match fails explicitly), the Elastic IP moves last, DNS never changes, and the retired resources are kept until Donnie approves retire.scripts/data-ui rebirth --adopt-data|--fresh-data redeploys every manifest app from its recorded release image (DEPLOY_RECORDED_RELEASE=1: pull-or-die, no compile/build/tag; the record’s model hash is checked against the checkout first — a mismatch dies; a full-SHA mismatch proceeds with a warning). --fresh-data also materializes the S3 manifest locally and restores each app’s freshest complete backup set (~/bin/<app>-backup recover prints the order; the restore runs inside a per-app child envelope so the supervisor survives failures). A populated destination files tree dies demanding REBIRTH_ALLOW_POPULATED_FILES=1. REBIRTH_APPS="a b" overrides the inventory; REBIRTH_ALLOW_BUILD=1 builds at HEAD instead. Rebirth never touches DNS or manifest rows. Every restore runs the automatic post-restore orphan sweep: a NOT-SAFE verdict on the final restore of the printed set halts the rebirth there with the healing pointer in hand (the app is up — stop-the-line for the report, not an outage; retry after healing with snapshot sweep-orphans prd:<app>); an earlier restore’s verdict only warns (SWEEP_VERDICT_FATAL=0 set per iteration, only inside the rebirth loop) so the sequence reaches the fresher data first. That warning rule is the rebirth loop’s alone — never generalize it to hand-run restore sequences.ops/prod-2-aws.sh bake; ops/prod-2-host.sh base): OS packages, Docker, k3d (checksum-verified), kubectl, HAProxy baseline (ops/prod-2-haproxy.cfg), certbot, Roswell + the SBCL/Quicklisp world parsed from the Dockerfile, the macnod user (fixed UID 1500), the sudoers rule, the fstab label line, pre-pulled base images, and the Docker drop-ins (LimitNOFILE, and RequiresMountsFor=/data — the cluster never starts on an unmounted /data). No cluster, no credentials, no data. Re-bake on host-setup changes and at least every 90 days; a re-baked AMI earns Validated=true only by passing the scratch restore drill.evo-x2/ prefixes onto prod-2/ (ops/prod-2-aws.sh lifecycle — a merge, never a replace), plus a 90-day noncurrent expiry under prod-2/site/. Backups run from prod-2 under the prod-2/ prefix with the same scripts and timers (~/bin/<app>-backup start); RESTORE_SITE=evo-x2 reads the source site during a move.ops/prod-2-prune.timer, daily 09:40 UTC) clears BuildKit cache and every unused deploy image on the host and in the k3d node, under the deploy lock.Project=data-ui-prod-2), e-mail at $150 and $200 actual (ops/prod-2-aws.sh budget; never an automatic stop).ops/prod-2-aws.sh: foundation, bake, launch [--fresh-data|--adopt-data|--from-snapshot] [--az AZ] [--scratch], publish-eip, snapshots-policy, lifecycle, budget, replace, ssh-allow, add-app <name> <domain>, retire <instance-id>. It requires an administrator AWS_PROFILE on the control host; every lookup is by tag, every returned scalar is checked, and nothing depends on evo-x2 surviving. Adding an app to prod-2 is add-app (an administrator widens the role’s A-record condition and creates the ECR repository) followed by the smoke lifecycle.ops/prod-2-aws.sh ssh-allow from any machine with the administrator profile re-points the rule (the forwarder’s ssh timing out is the symptom).DEPLOY_HOST=prod-2 scripts/data-ui deploy <app> (from evo-x2; DNS still answers from evo-x2).RESTORE_SITE=evo-x2 ~/bin/<app>-backup recover, then snapshot restore <name> prd:<app> per printed name; verify row counts, the files tree, an admin login, and pinned health. Each per-name snapshot restore is its own process and the sweep is automatic: a NOT-SAFE verdict exits 1 after the “Restored snapshot” line — the restore itself did not roll back, the database is the dump, and the prerestore slot still holds the destination’s previous state (restoring that slot is the deliberate undo if the operator wants it); the operator heals per the sweep’s report or judges, and a multi-name trial continues by running the next printed name. “Earlier restores only warn” is the rebirth loop’s rule and only its rule — never this runbook’s.~/bin/<app>-backup stop.kubectl -n dataui-<app> scale deploy/dataui-<app> --replicas=0; kubectl -n dataui-<app> wait --for=delete pod -l app=dataui-<app> --timeout=120s). PostgreSQL stays up; snapshot save works against a scaled-down app.~/bin/<app>-backup run (SceneBook: run daily); confirm the triple in S3.snapshot restore, automatic sweep, NOT-SAFE verdicts fatal per name); row counts must now equal the fenced source.scripts/data-ui cutover <app>.dig +short A <domain> @1.1.1.1 shows the Elastic IP; curl -fsS --resolve <domain>:443:<EIP> https://<domain>/health; a login from outside the home network.<domain> → the Elastic IP) and, immediately, the same line in evo-x2’s /etc/hosts — the home LAN’s split-horizon DNS otherwise keeps resolving the name to evo-x2 (the agents’ backlog wrapper depends on this step).~/bin/<app>-backup start plus one run; verify fresh objects under prod-2/<app>/.scripts/data-ui delete <app> (the farewell snapshot prd-<app>-last stays in evo-x2’s pool).Before step 7 nothing is public and everything can be put back; after step 7 never un-fence evo-x2 — fix forward on prod-2, or reverse deliberately.
ops/prod-2-aws.sh ssh-allow.cutover (or its re-run) is usually the missing step.REBUILD=1 repairs the cache).DEPLOY_HOST=prod-2 (or MOVE=1 for a deliberate move back).deploy-bootstrap (beyond creating/validating the production clone) also migrates legacy VIP identities: it inventories models/local/*.lisp in every checkout production historically deployed from (the bootstrap/development checkout, plus any existing production clone), cross-checks them against live dataui-* namespaces, and copies each file bytes-intact (SHA-256 verified) to the production clone’s models/local/<declared-name>.lisp under the production lock. It refuses to overwrite a different destination file, rejects malformed names, declared-name mismatches, conflicting duplicates, and symlink sources for operator resolution, and never modifies the legacy checkout. An empty inventory is printed and is fine. An instance whose identity cannot be inventoried requires MODEL_FILE=<archived model file> scripts/data-ui delete NAME.
Configuration knobs (environment variables, all with defaults):
| Variable | Default | Meaning |
|---|---|---|
DEPLOY_HOST |
evo-x2 (the site marker on a stamped host defaults it to that site) |
ssh destination & site identity (production) |
STAGING_HOST |
evo-x2 |
staging host (must equal DEPLOY_HOST) |
DEPLOY_CHECKOUT |
/data/data-ui/repos/production |
production clone |
STAGING_CHECKOUT |
/data/data-ui/repos/staging |
staging clone |
DEPLOY_BOOTSTRAP_CHECKOUT |
~/common-lisp/data-ui |
last-resort launcher on a host with no production clone |
CHECKOUT_LOCK_ROOT |
/data/data-ui/repos |
deploy/staging lock directory |
DATA_UI_PUBLIC_URL / DATA_UI_PRIVATE_URL |
canonical GitHub URLs | clone URLs (prod-2’s site default is the anonymous HTTPS URL) |
DEPLOY_STATE_DIR |
/data/data-ui/deploy |
state directory |
DATA_UI_STATE |
/data/data-ui |
root for deploy state (and the site marker, <root>/site) |
MODEL_FILE |
(unset) | explicit model file (VIP deploys and delete identity) |
K3D_CLUSTER |
evo-x2 (site default on prod-2: prod-2) |
k3d cluster name |
IMAGE_REGISTRY |
(unset; site default on prod-2: the ECR registry) | registry cache for deploy images |
REBUILD |
(unset) | 1 skips the registry probe, builds, and pushes over the same content tag |
MOVE |
(unset) | 1 overrides the wrong-site guard and pins gate 2 to loopback |
SITE_DNS_MODE |
wildcard (site default on prod-2: explicit) |
how publication works on this site |
SITE_DNS_ZONE_ID |
(unset; prod-2: Z0152779JVWMFEK6RAKU) |
Route 53 hosted zone for per-app records |
SITE_WILDCARD_ZONE |
(unset; stamped evo-x2: demo.data-ui.com) |
arms the wrong-site guard |
SITE_STATE_URI |
(unset; prod-2: s3://data-ui-backups-232168665831/prod-2/site) |
S3 prefix for release records and the manifest |
SITE_PRODUCTION_ONLY |
(unset; prod-2: 1) |
refuse staging/demo/profile verbs outright |
SITE_PUBLIC_IP / SITE_HEALTH_IP |
(unset; IMDSv2 on prod-2) | pin the site’s address / the health gates |
DEPLOY_RECORDED_RELEASE |
(unset) | 1 = redeploy the recorded image (the rebirth path) |
REBIRTH_APPS / REBIRTH_ALLOW_BUILD / REBIRTH_ALLOW_POPULATED_FILES |
(unset) | rebirth overrides (see Two Production Sites) |
DRY_RUN |
(unset) | see Dry Runs |
STAGING_HEALTH_TIMEOUT |
300 |
per-profile restart gate deadline (seconds) |
MODELBANK_DRAIN_TIMEOUT |
600 |
Model Bank drain deadline (seconds) |
git status --porcelain --untracked-files=all to be empty in the production clone (ignored files like web/dist, web/node_modules, and models/local/ are fine). A dirty clone aborts with no build, no git clean, no reset --hard, no auto-stash, and no force — including under DRY_RUN and MODEL_FILE. A local branch that is ahead, diverged, or whose upstream rewound aborts (the fast-forward merge exits 0 even when the local branch is ahead, so a post-merge recheck of branch, upstream, and HEAD is the gate).production.lock (deploy, delete, the production half of staging update and activation) and staging.lock live under $CHECKOUT_LOCK_ROOT. A deploy holds the production lock across selection, compile, build, rollout, both health gates, and promotion; DRY_RUN=1 takes it like a real deploy (the compile database on port 5446 is one global resource, and the lock serializes a developer’s dry run against a Model Bank worker’s deploy). The lock is a flock on a descriptor that is inherited across the production re-exec; it is released when the last descriptor closes.The Docker context is never the raw checkout (Dockerfile uses COPY ., and ignored stale VIP models under models/local/ would ride into canonical images). Instead the inner deploy builds a fresh restrictive temp directory populated by git archive <full SHA>:
models/local path in the archive listing aborts the build — the tracked root .dockerignore exists and rides along in the archive, but it never excluded models/local/; it is not isolation.models/local/ in the context, copies the immutable handoff candidate there as models/local/<name>.lisp, SHA-256-checks it against the snapshot the outer arm took, and asserts the archived canonical models/<name>.lisp is absent; a canonical deploy asserts no models/local/ path exists in the context.A VIP deploy’s model text crosses as data: the Model Bank worker writes a unique file models/local/deploy-incoming/<token>.lisp in its staging checkout (exclusive create; no worker ever mutates another’s input), and the outer deploy snapshots and validates it (regular file, ≤1 MiB, no symlinks, SHA-256) before any Git or network mutation, then installs its own candidate at the same relative path in the production checkout — under the production lock, the only writer. The inner arm compiles, builds, and rolls out from that candidate.
models/<cli-name>.lisp exists in the selected revision, the deploy is refused right after selection and before compilation: resolve-model-path prefers the canonical file, so the image would silently run it instead of the VIP model. Never delete or overwrite the canonical file to make a VIP deploy fit.deploy <name> is canonical and succeeds; a VIP re-deploy of that name is refused, naming the upstream canonical file as the reason; and the canonical promotion removes the now-stale stable models/local/<name>.lisp, reporting the removal, so a bare delete resolves the canonical identity.update_haproxy, and both production health gates (the NodePort /health gate and the public-domain /health gate) does a VIP deploy rename its candidate onto the stable models/local/<name>.lisp; workers never write the stable copy. Failures and dry runs leave any prior stable copy byte-identical.apply_manifests removes the candidate. A failure after apply_manifests begins preserves it as $DEPLOY_STATE_DIR/<name>/recovery/<SHA>-<token>.lisp (mode 600) and prints MODEL_FILE=<recovery path> scripts/data-ui delete <name> — a failed :domain change may have left a route only the record describes. Only an operator removes recovery records; a later successful deploy prints any it finds but never deletes them.deploy-incoming/ (bytes intact) to $DEPLOY_STATE_DIR/orphaned-candidates/<UTC timestamp>-<basename> — it may be the only identity of an instance a killed deploy rolled out.DRY_RUN=1 scripts/data-ui deploy todos
A dry run is not side-effect-free: it still fetches and fast-forwards the production checkout, compiles the model through the throwaway database, and writes deploy state (manifests, ports.lock, secrets cache). It skips tagging, image build, and cluster mutation, and never waives cleanliness or source verification. With a handoff it runs the same validation path and its exit trap removes the temporary candidate, so models/local/deploy-incoming/ ends byte-identical and nothing is promoted.
If the model was deployed with :repl t, the container runs a Swank server on port 4005, reachable only through Kubernetes port forwarding (it is never exposed via Service, NodePort, or HAProxy):
kubectl -n dataui-todos port-forward deploy/dataui-todos 4005:4005
Then in Emacs: M-x slime-connect RET localhost RET 4005, and you have a live REPL inside the running production container. Inspect the compiled model, poke RBAC state, debug a hook: the full Lisp experience against the deployed instance. With great power, et cetera: this is the expert-tier escape hatch, and production models should ship :repl nil.
Work from the inside out; each rung isolates one layer:
# 1. Are the pods up?
kubectl -n dataui-todos get pods
# 2. Does the app answer inside the cluster? (NodePort, bypasses HAProxy)
curl http://<node-ip>:30303/health # expect: OK
# 3. Does HAProxy route it? (full path: TLS, map, backend)
curl https://todo.demo.data-ui.com/health # expect: OK
# 4. Does login work? (POST the real admin password; see Secrets)
curl -s -X POST https://todo.demo.data-ui.com/api/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"<see Secrets section>"}'
# 5. Login still 401s? Read the Secrets section again — a deploy
# never rewrites admin credentials, so the password is exactly
# what the cluster Secret says.
If (2) works and (3) doesn’t, it’s HAProxy: check /etc/haproxy/data-ui.map for the domain, /etc/haproxy/conf.d/ for the backend file, and remember the reload-vs-restart subtlety above.
kubectl -n dataui-todos logs deploy/dataui-todos # current
kubectl -n dataui-todos logs deploy/dataui-todos --previous # last crash
The app logs structured JSON lines. A crash prints a full backtrace and exits (--disable-debugger), so the evidence is always in --previous.
.dockerignore excludes *.log now, but entropy never sleeps.RUN ros step, low I/O, ~1 core CPU): first build after the Ubuntu 26.04 upgrade (Sept 2026): BuildKit RUN processes inherited the daemon’s LimitNOFILE=infinity (=2147483584), and SBCL’s startup fd sweep (close() across the whole fd space) takes minutes at that limit — one ros install sbcl-bin went from ~2s to 592s. Two fixes, both in place: a systemd drop-in (/etc/systemd/system/docker.service.d/limit-nofile.conf, LimitNOFILE=1048576) and ulimit -n 1048576 && prefixes on every RUN ros … in the Dockerfile (host-independent). Verified: same step 592s → 4s.pass credential store and gpg prompted. Should be extinct since the store moved to a no-passphrase key — see Docker Credentials: Headless Deploys. If it returns, first suspect a new credsStore entry in ~/.docker/config.json (a stray docker login on another host user), not the store itself.scripts/data-ui traffic reports the HAProxy per-IP rate-limit counters (stick-table in the https frontend) and flags clients near or over the limits. It needs sudo for the HAProxy admin socket.
The fast path: delete the whole instance with one command:
scripts/data-ui delete todos
It deletes the namespace and PVs, wipes the instance’s data on the host, removes the HAProxy backend and map entry, and removes the deploy state (including secrets), then prompts you to type the instance name before doing any of it (set FORCE=1 to skip the prompt, e.g. in a deploy/record/delete rehearsal loop). Before destroying anything it saves a farewell snapshot of the instance’s last state to the shared pool as prd-<name>-last (the prd twin of the stop verb’s -last slot; FORCE=1 skips that too, and a failed save aborts the delete with the data still intact). Docker images, git release tags, and the farewell snapshot are left alone. A failed delete can simply be re-run; every step tolerates already-deleted resources, and the re-run skips the farewell (nothing left to save).
The manual equivalent, if you want to do it piecewise (or only partway; steps 1–3 are enough for a clean redeploy of the same instance):
# 1. Remove the app and its namespace
kubectl delete namespace dataui-todos
# 2. PVs are cluster-scoped with Retain policy; delete them explicitly
kubectl delete pv dataui-todos-demo-db-pv dataui-todos-demo-files-pv
# 3. Wipe the instance's data on the host (root-owned; same path
# on host and node via the /data/k8s bind)
sudo rm -rf /data/k8s/data-ui/todos-demo
# 4. Optional: drop cached secrets to get fresh credentials
rm /data/data-ui/deploy/todos/secrets.env
# 5. Deploy
scripts/data-ui deploy todos
Steps 2 and 3 are the ones people forget. A Released PV refuses to bind to a new claim, and stale postgres data under /data/k8s/data-ui will be happily adopted by the new instance, old password and all. (Or skip the list entirely and use scripts/data-ui delete, which forgets nothing — except the farewell snapshot it deliberately leaves in the pool.)
That’s the machine. A napkin’s worth of model in, a running application out: database, API, RBAC, frontend, TLS, DNS, all of it derived, none of it hand-maintained. The 10,000 lines you didn’t write are the feature.