ADR-0053: Run everything together¶
Status: Accepted Date: 2026-10-24 Deciders: Alex Nodeland
Context¶
Running the whole system on one machine took two make ups and secrets copied by hand. The generated application is a Compose project of its own (name: its slug) beside stackr's stackr project. It reaches the stack by the external networks stackr, supabase_network_stackr-supabase and stackr-umami. Its .env needs:
- Langfuse's keys;
- the database's addresses and owner;
- GoTrue's issuer, keys and admin API on the postgres adapter;
- two gateway keys;
- analytics' and Umami's passwords.
Only the smoke test's make smoke-app did all of this, and only for itself.
Decision¶
One command, make dev, at lattice's root, keeps the two Compose projects and does the wiring between them. make dev-down, make dev-status and make dev-reset go with it. scripts/dev holds the steps, and make only calls it, so no recipe line shows a key.
- The stack runs on the postgres adapter, with GoTrue, and with
observability langfuse gateway auth analytics umami. Umami runs on that adapter alone. A stackr with no.envis givenSTACKR_DATABASE=postgres. One whose.envchooses local Supabase is refused, not switched, since that is a running stack's. - What it needs is checked before anything starts.
- Copier comes from stackr's dev group, at
uv.lock's version. Where lattice's.venvhasn't it,make devinstalls that group alone, withuv sync --locked --inexact --package stackr --only-group dev. That adds to.venvand changes no file of lattice's, unlikemake install's Bun packages, browser and git hooks. - A
stackrproject's PostgreSQL volume from an earlier stack keeps the admin password it was made with, and a different one in.envwould make db-init fail halfway. So where there is such a volume (found by its Compose labels), PostgreSQL alone is started, or the running one used, and signed in to with.env's password over the container's own address, as db-init signs in from another container. The image trusts its loopback and socket, where any password would pass. The password goes topsqlin its environment, never as an argument, and is never printed. If psql says the password failed, nothing else starts, and the message gives the two ways out: use the.envthat made the volume, ormake dev-reset. Any other failure is reported with what psql said. Either way, the PostgreSQL it started may be left running, andmake dev-downstops it.
- Copier comes from stackr's dev group, at
- The application lives in
.local/run/portal, inside the clone, where.gitignorekeeps it out of lattice's history. It is a repository of its own, ascopier updateand its hooks need. It is generated beside that directory and moved there once whole, so a run that dies leaves nothing half-made in its place; a directory there thatmake devdidn't generate is refused. A render under.locallocks and syncs as a project of its own, and lattice's workspace also saysexclude = [".local"], so it never becomes a member.DEV_APP_DIRputs it elsewhere, but never around lattice itself. - It is generated once, as the smoke test generates it:
copier copy --vcs-refat lattice'sHEAD, with nolibraries_path. Its image installs the libraries from GitHub at that commit.make devfetches origin and refuses a commit that isn't there, before anything starts, andDEV_REFnames another. It is generated before the stack starts, and committed with an identity of its own where this machine's git has none, without hooks. An application generated from another commit thanDEV_REFis said, withcopier updateas the way to move it. - The defaults:
- The template's defaults, the portal among them.
- Every crafting app the template pins without a
platform:, so none built for one platform alone, on any machine: today that leaves out Blender. The list comes fromcopier.yml, so it doesn't drift. - Diagrams on, replay off, and everything bound to
127.0.0.1. ASTACKR_BINDorAPP_BINDbeyond the loopback is refused before anything starts; the LAN needs an explicit opt-in,DEV_LAN=yes. - The crafting apps are written only while
.envdoesn't choose them, so a choice of your own stays.DIAGRAMScomes fromDEV_DIAGRAMS(on) on every run, since the template's own default,off, can't be told from a choice.
- Secrets stay in files.
- The gateway keys are made once, by stackr's
create-tenant(asDEV_TENANT) andcreate-portal-key, each only when the application's.envlacks it. - Each goes from its script's output into stackr's
scripts/wire-appon stdin, then into the application's.env, mode 0600, as soon as it is made: a later failure doesn't lose it. They are never printed or passed as an argument. A key the gateway has but can't give back stops the run, with how to recover. scripts/wire-appgives the.envthe rest of the stack's settings. Each key has one line, somakeand Compose read the same value. The smoke test now uses it too.
- The gateway keys are made once, by stackr's
- The database role is made with
db-rolesin the application's container before it starts, as the smoke test does. That, the image's build and the start run every time, and change nothing that is already so. The first person in, which asks for a password, ismake first-runin the application's directory, andmake devsays so;scripts/wire-appgives the local commands the database and GoTrue as this machine reaches them. - Running it again is safe. It generates the application and makes the keys once.
make dev-downruns each project's ownmake down, the application's first, which keeps their data.make dev-resetdeletes the containers and volumes of exactly the two projects, the application's (as itscompose.yamlnames it, which must be a project name and notstackr) and thenstackr, withdocker compose -p <name> down --volumes, once you typeyesin a terminal. It shows the Docker context first, and says thatstackris the one stack every clone and worktree on the machine shares.COMPOSE_PROJECT_NAMEand the otherCOMPOSE_*settings are unset, so neither project is renamed.down -p <name>needs no compose file: Compose v2, whichmake devchecks for, finds a project's containers and volumes by its labels. Nothing else of Docker's is removed. The gateway's keys went with the stack's data, so reset takes them out of the application's.env, and the nextmake devmakes new ones.
Amended (2026-10-27) by portalr ADR-0084: the application in
.local/run/portalgetsPORTAL_EXTRA_URLSand the newmake tailnetbycopier update.make tailnetin its directory is the one other writer of its.env: one key,PORTAL_EXTRA_URLS, in place and mode 0600 kept, whichmake tailnet-offremoves;scripts/wire-appandmake devleave it as it is, andmake up(ormake dev) applies it.
Consequences¶
- One command runs the system as a person would use it, at the clone's committed and pushed code.
- Library changes not yet pushed aren't in the application's image. The smoke test has the same limit.
make devcan't be tested end to end in CI without a second stack.scripts/check-devruns it against fakes, as the root'scheck-devtask: its order, what it refuses before anything starts, its keys kept through a failure, a failed generation, and whatresetdeletes.scripts/wire-appis checked byscripts/check-make, and the smoke test exercises it on every Smoke job.
Options considered¶
- One Compose project for the stack and the application. One
upand onedown, but the application'scompose.yamlwould have to become part of stackr's, or include it, and the template's application would no longer run beside a stack it doesn't own, as on a single host or another machine's. Not chosen: two projects behind one command keep each as it is. - Two projects behind one command. Chosen: each project's own commands keep working in its directory, and the wiring between them is the one thing added.
- Building the application from the clone's libraries (Compose
additional_contexts). See the follow-up below.
Follow-up¶
- Building from a local checkout. An optional build context for the libraries (Compose
additional_contexts) would let the application's image install them from the clone, unpushed changes included. That is a change to every library's install in the template, and needs a decision of its own.
Amendment (2026-10-30)¶
The owner decided that make dev updates the application when lattice has moved, rather than only saying so.
- When the application was generated from another commit than
DEV_REF(defaultHEAD),uprunscopier update --quiet --defaults --vcs-ref <DEV_REF's commit>in it, keeping its answers, thenuv lockthere (an update can changepyproject.toml, and the image builds withuv sync --locked), and commits the result in the application's repository aschore: update from template. The commit must be on origin, as for a new application. - It refuses, before anything starts, an application with uncommitted changes (they are not mixed into the update), and an update that leaves conflicts,
.rejfiles or conflict markers, naming the files. The update's changes are left in the application for a person to resolve and commit. scripts/check-devchecks the update, the relock and its commit, the refusal of uncommitted changes, and both kinds of conflict, against its fakes. A realcopier updateis not run there.