Registry mode: publish app/web/migrate images, drop source builds on hosts
The federated suite now installs Superbrain like every other house app:
pull images, run installapp, no source tree on the host.
Images (Docker Hub, federatedcomputer namespace, one shared tag per
release + :latest, linux/amd64 + linux/arm64):
superbrain-app Go API (scratch)
superbrain-web Next.js standalone
superbrain-migrate NEW self-contained db image: db/ baked in, entrypoint
db/bootstrap.sh waits for postgres, applies
schema.sql AS DB_USER on an empty database (object
ownership — migrations must be able to ALTER), then
always runs the checksummed ledger. Fresh install and
upgrade become the same command. The dev compose runs
the same bootstrap.sh (verified: non-empty DB skips
schema, applies pending migrations).
Release CI (.github/workflows/release.yml): semver tags without v prefix
(the suite's VERSION_RX); a smoke job bootstraps a throwaway PostgreSQL
with the migrate image (fresh schema + complete ledger + idempotent re-run)
and runs Go build/vet/unit BEFORE the publish job pushes — a broken db/
can never reach a tag the upgrade flow will pull. Requires
DOCKERHUB_USERNAME/DOCKERHUB_TOKEN secrets. Dockerfile stays legacy-
builder compatible (no BUILDPLATFORM cross-compile): dev hosts build
locally; CI builds each arch natively under qemu.
Federated integration:
- lib-superbrain.sh: compose pulls federatedcomputer/superbrain-*:
${IMAGE_VERSION} (bookstack quoting), no build: keys, no
IMAGE_VERSION_HOLD; compose generation extracted into
render_superbrain_compose (install + update share it); schema.sql
pre-apply and host image builds removed; IMAGE_VERSION is the only
VERSION= line in the generated .env (upgrade_app's sed matches every
occurrence — the file says so in words that don't contain the pattern).
- service file: CONTAINER=federatedcomputer/superbrain-app (must equal the
first image: repository — upgrade_app compares it), VERSION=1.0.0.
- services/superbrain/upgrade/pre hook (listmonk pattern): pre-upgrade
pg_dump into .update-backups (5 retained) + pulls web/migrate at the
target version (upgrade_app pulls only the app image).
- install.sh: registry messaging, installs the upgrade hook, clone is only
for deploy files now.
- update.sh REWRITTEN for registry mode: the app dir no longer contains
source, so it runs from a repo clone — sync lib/service/hook (parse-
checked, backed up) -> re-render compose -> /federated/bin/upgrade
superbrain -> same-version compose safety pass -> health probe.
- STRATEGY.md interim-mode section replaced with the registry-mode record.
README: federated section updated (pulls, not builds; house upgrade flow)
and a new 'Environment variable reference' section — every variable the
stack reads, required/optional, defaults, grouped (core, compose, access
policy, OIDC, SMTP, AI, federated-only, tests-only), so generated .env
files stay correct as features are added.
This commit is contained in:
@@ -41,33 +41,55 @@ probe). Source-on-host builds fight that machinery, so:
|
||||
|
||||
**Decision: publish versioned images from CI; the host never builds.**
|
||||
|
||||
**Interim mode (implemented now, 2026-10-25):** until CI publishes images,
|
||||
`lib/superbrain.sh` builds from source staged at `/federated/tmp/superbrain-src`
|
||||
(tar-synced from the workstation; the exact command is in the script header).
|
||||
For OTHER federated cores (any operator with repo access),
|
||||
`deploy/federated/install.sh` packages the whole flow: preflights the suite
|
||||
(Authelia required — the core tier is SSO-only — plus the fcore SMTP
|
||||
credential source), stages the source by `git clone` (or `$SUPERBRAIN_SRC`),
|
||||
installs `lib/superbrain.sh` + `services/superbrain/service` (with fixed-IP
|
||||
collision checks and `SUPERBRAIN_*_IP` overrides), runs
|
||||
`/federated/bin/installapp superbrain`, then verifies containers, the
|
||||
Authelia client + claims policy, and the HTTPS login page.
|
||||
Images are tagged `superbrain-app:local` / `superbrain-web:local`, `.env`
|
||||
carries `IMAGE_VERSION_HOLD=1` so the generic `upgrade` flow skips the app
|
||||
cleanly, and the service file's `CONTAINER=superbrain-app` matches the
|
||||
first `image:` line of the generated compose so `upgrade_app`'s rewrite-sed
|
||||
can never mangle it. **Updates** in interim mode run through
|
||||
`deploy/federated/update.sh` (shipped inside the app dir): clone at REF →
|
||||
pre-update pg_dump (5 retained) → sync (`.env`/data untouched) → refresh
|
||||
lib+service files → build → force-recreate → health probe → automatic
|
||||
rollback to the previous image tags on failure. A deliberate non-goal: an
|
||||
in-app "update" button — the scratch containers have no docker socket and
|
||||
must never get one (read_only + cap_drop ALL is the hardening model);
|
||||
host-level operator action is the trust boundary until registry mode.
|
||||
Switching to registry mode later = publish images, drop the
|
||||
`build:` keys + hold marker, point `CONTAINER`/`VERSION` at the registry —
|
||||
at which point the house `upgrade` flow and panel button take over and
|
||||
update.sh retires.
|
||||
**Registry mode (implemented 2026-10-29):** CI publishes the three images —
|
||||
`federatedcomputer/superbrain-{app,web,migrate}` — on semver tags without a
|
||||
`v` prefix (`.github/workflows/release.yml`, tag filter `[0-9]+.[0-9]+.[0-9]+`,
|
||||
linux/amd64 + linux/arm64, one shared tag per release plus `:latest`; a
|
||||
smoke job bootstraps a throwaway PostgreSQL with the migrate image — fresh
|
||||
schema + full ledger + idempotent re-run — before anything is pushed). The
|
||||
migrate image is self-contained: `db/` is baked in and its entrypoint
|
||||
`db/bootstrap.sh` waits for postgres, applies `schema.sql` **as the
|
||||
superbrain user** on an empty database (object ownership: migrations must
|
||||
be able to ALTER those objects), then always runs the checksummed ledger —
|
||||
so a server never needs the source tree, and fresh install and upgrade are
|
||||
the same command. The dev compose runs the same bootstrap.sh.
|
||||
|
||||
The generated app-dir compose pulls `federatedcomputer/superbrain-*:
|
||||
${IMAGE_VERSION}` (`.env`, bookstack quoting style), no `build:` keys, no
|
||||
`IMAGE_VERSION_HOLD`. The service file sets `CONTAINER=
|
||||
federatedcomputer/superbrain-app` (must equal the first `image:` line's
|
||||
repository — `upgrade_app` greps it) and `VERSION=<release>`; the
|
||||
`.env` keeps `IMAGE_VERSION=` as its ONLY line containing `VERSION=`
|
||||
because `upgrade_app`'s rewrite-sed matches every occurrence.
|
||||
`services/superbrain/upgrade/pre` (house hook mechanism, listmonk
|
||||
pattern) takes a pg_dump into `.update-backups/` (5 retained) and pulls
|
||||
web+migrate at the target version, since `upgrade_app` itself pulls only
|
||||
the app image.
|
||||
|
||||
Install/update for any core: `deploy/federated/install.sh` (preflights —
|
||||
Authelia required, fcore SMTP credential, fixed-IP collisions with
|
||||
`SUPERBRAIN_*_IP` overrides; installs lib/service/hook; runs
|
||||
`/federated/bin/installapp superbrain`; verifies containers, Authelia
|
||||
client + claims markers, HTTPS login) and `deploy/federated/update.sh`
|
||||
(clone at ref → sync lib/service/hook with parse-checks and backups →
|
||||
re-render compose via `render_superbrain_compose` → `/federated/bin/
|
||||
upgrade superbrain` → same-version compose safety pass → health probe).
|
||||
The registry-mode app dir holds ONLY compose + .env — update.sh therefore
|
||||
runs from a repo clone, not from the app dir (the source-mode
|
||||
self-location of the old update.sh died with interim mode).
|
||||
|
||||
A deliberate non-goal remains: an in-app "update" button — the scratch
|
||||
containers have no docker socket and must never get one (read_only +
|
||||
cap_drop ALL is the hardening model); host-level operator action (or the
|
||||
house panel, which shells out on the host) is the trust boundary.
|
||||
|
||||
History: interim source-build mode (2026-10-25..29) staged a tar-synced
|
||||
source tree at `/federated/tmp/superbrain-src`, built `superbrain-{app,
|
||||
web}:local` on the host, pinned `IMAGE_VERSION_HOLD=1`, and updated via a
|
||||
source-rebuilding update.sh with image-retag rollback. Its installer
|
||||
preflights and IP-collision logic carried over unchanged. The clobber
|
||||
lesson also carried over: never `cp -a` a repo tree over the app dir — the
|
||||
generated compose must survive (hit in production 2026-10-29).
|
||||
|
||||
For the registry target:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user