Registry mode: publish app/web/migrate images, drop source builds on hosts
release gate / check (push) Canceled after 4m3s
release / smoke (push) Successful in 10m13s
release / publish (push) Failing after 12m48s

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:
Andrew S Erwin
2026-10-29 10:21:10 -05:00
parent 0dc48a137f
commit 341cdce026
12 changed files with 582 additions and 295 deletions
+106 -16
View File
@@ -367,12 +367,15 @@ The installer:
plus the house mail relay credential for notification emails, the
`core` docker network, and fixed-IP availability (override with
`SUPERBRAIN_{WEB,APP,MIGRATE}_IP` on collision).
2. **Installs the house integration** — `/federated/lib/superbrain.sh` and
`/federated/services/superbrain/service`, then runs the standard
`/federated/bin/installapp superbrain`: compose + `.env` generation
(`TIER=core`), image builds from the staged source (interim mode until
CI publishes registry images), database + user on the shared postgres,
pdns record, monitors, superpanel catalog entry.
2. **Installs the house integration** — `/federated/lib/superbrain.sh`,
`/federated/services/superbrain/service` and the `upgrade/pre` hook,
then runs the standard `/federated/bin/installapp superbrain`: compose +
`.env` generation (`TIER=core`), **image pulls from Docker Hub**
(`federatedcomputer/superbrain-{app,web,migrate}`, one shared version
tag, amd64 + arm64 — no source, no builds on the host), database + user
on the shared postgres (the migrate image bootstraps the schema and
runs the ledger itself), pdns record, monitors, superpanel catalog
entry.
3. **Registers the Authelia OIDC client** — including the `claims_policy`
that puts `email` in the ID token (without it every SSO login fails
with AccessDenied), validated before Authelia is restarted.
@@ -386,20 +389,107 @@ Prerequisites: Authelia with the OIDC provider configured, shared
sender account). Full design record, IP plan, upgrade flow and incident
history: [deploy/federated/STRATEGY.md](deploy/federated/STRATEGY.md).
**Updating** an installed core (interim source-build mode) is one command
on the host:
**Updating** an installed core is the standard house flow — bump `VERSION`
in `/federated/services/superbrain/service` to the new release tag and run
`/federated/bin/upgrade superbrain` (the pre-hook backs up the database
and pulls all three images). Or one command, which also syncs the suite
files from the repo:
```bash
sudo bash /federated/apps/superbrain/deploy/federated/update.sh [git-ref]
git clone https://gitea.federated.computer/Federated_Computer/brain.git /tmp/superbrain-repo
sudo bash /tmp/superbrain-repo/deploy/federated/update.sh [git-ref]
```
It clones the requested revision (default `main`), takes a pre-update
`pg_dump` (last 5 kept under the app dir), refreshes the suite integration
files, rebuilds the images, recreates the stack (migrations run
automatically), health-probes both containers, and **rolls back to the
previous images automatically on any failure**. When CI starts publishing
registry images, the generic house `upgrade` flow and the panel button
supersede this script (drop `IMAGE_VERSION_HOLD=1` from the app `.env`).
Releases are semver tags without a `v` prefix (`1.0.0`); CI builds and
pushes all three images under the same tag (plus `:latest`) for
linux/amd64 and linux/arm64. The migrate image is self-contained: it
detects an empty database, applies `schema.sql` as the superbrain user,
then runs the checksummed migration ledger — the host never needs the
source tree.
## Environment variable reference
Everything the stack reads, so a generated `.env` (or hosting environment)
stays correct as features are added. `.env.example` carries the same list
with annotations. "Required" means the app refuses to start or the feature
is off without it.
### Core (every deployment)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `AUTH_SECRET` | **yes** | — | Signs NextAuth JWTs, Go session cookies, proxy assertions and service tokens. Keep stable: rotating it signs everyone out and (without `ENCRYPTION_KEY`) invalidates stored IMAP passwords. `openssl rand -base64 32` |
| `NEXTAUTH_SECRET` | no | `AUTH_SECRET` | Alternative name; takes precedence when both are set (both sides use the same precedence) |
| `NEXTAUTH_URL` | **yes** in production | — | Exact browser-facing origin. Drives OIDC callbacks, the proxy's origin allowlist, cookie-secure derivation and password-reset links |
| `ENCRYPTION_KEY` | no | derived from `AUTH_SECRET` | Dedicated key for stored credentials (IMAP passwords, notification channel secrets, BYO AI keys). Set it and rotating `AUTH_SECRET` no longer touches them. Back it up with the database |
| `COOKIE_SECURE` | no | derived from `NEXTAUTH_URL` scheme | Set `0` explicitly only for local HTTP |
| `DATABASE_URL` | **yes** (Go) | — | `postgres://user:pass@host:5432/db?sslmode=disable`; `DB_URL` is the Makefile fallback |
### Compose stack (repo `docker-compose.yml`)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `POSTGRES_PASSWORD` | **yes** | — | Fail-fast `:?` interpolation — compose refuses to start without it |
| `POSTGRES_VOLUME` | no | `superbrain_pgdata` | Data volume name |
| `POSTGRES_VOLUME_EXTERNAL` | no | `false` | `true` to mount a pre-existing volume |
| `APP_HOST_PORT` / `WEB_HOST_PORT` | no | `8080` / `3000` | 127.0.0.1 host bindings; when shifting `WEB_HOST_PORT`, `NEXTAUTH_URL` must match the browser-facing origin |
| `PORT` | no | `8080` | Go listen port inside the container |
### Access policy (tier & auth shape)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `TIER` | no | unset | `core` (Authelia-only) or `multi` (self-service signup); derives the three below. Invalid values fail startup |
| `AUTH_MODE` | no | tier-derived, else `both` | `both` / `password` / `oidc` — overrides the tier. Invalid values fail startup |
| `SIGNUP_ENABLED` | no | tier-derived, else on | `0` closes self-service registration |
| `ALLOW_BOOTSTRAP_SIGNUP` | no | tier-derived, else on | `0` stops the first signup from claiming admin (set `0` on any exposed host) |
| `ADMIN_EMAILS` | no | empty | Comma-separated operator addresses: reserved at signup, ADMIN at first SSO login, ADMIN via `--seed` |
| `TRUSTED_PROXY` | no | unset | `1` only when the proxy overwrites `X-Real-IP` (bundled nginx template does; traefik does not) — enables per-client rate-limit identity |
### Authelia OIDC (all three required for SSO; placeholders = off)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `OIDC_ISSUER` | for SSO | — | Exact issuer from Authelia's discovery document |
| `OIDC_CLIENT_ID` | for SSO | — | Must match the Authelia client |
| `OIDC_CLIENT_SECRET` | for SSO | — | The **plain** secret, not the digest |
### Transactional mail (password reset + notification email channel)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `SMTP_HOST` | for mail | — | Relay host; unset disables reset (503) and email delivery |
| `SMTP_PORT` | no | `587` | `465` = implicit TLS; otherwise STARTTLS when advertised |
| `SMTP_USERNAME` / `SMTP_PASSWORD` | no | — | AUTH PLAIN when the relay requires it |
| `SMTP_FROM` | **with SMTP_HOST** | — | Envelope+header sender |
| `NETGUARD_TRUSTED_HOSTS` | no | empty | Comma-separated operator-pinned hostnames allowed to resolve to private addresses (split-horizon relays). Never user-supplied names |
### AI (assistant, automations)
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `AI_API_KEY` | for the server-wide key | — | Operator fallback key; per-user BYO configs (Settings → AI) take precedence, and free/standard plans are BYO-only |
| `AI_MODEL` | no | `recursive/flint-v1.0:free` | Any model the provider serves |
| `AI_BASE_URL` | no | `https://openrouter.ai/api/v1` | Any OpenAI-compatible endpoint |
| `AI_PROVIDER` | no | `openai-compatible` | or `anthropic` / `gemini` |
### Federated suite installs only
| Variable | Required | Default | Purpose |
|---|---|---|---|
| `IMAGE_VERSION` | **yes** | `1.0.0` | Shared tag for the three registry images; `upgrade` rewrites it. Must be the ONLY `VERSION=`-containing line in the file (upgrade_app's sed matches every occurrence) |
| `DB_HOST` / `DB_USER` / `DB_NAME` / `PGPASSWORD` | **yes** | — | Shared suite postgres coordinates, read by the migrate image's bootstrap |
| `API_BASE_URL` | **yes** (web) | — | Server-only DNS to the Go container (`http://superbrain-app:8080`) |
| `AUTH_TRUST_HOST` | **yes** (web) | — | `true` behind the reverse proxy |
### Tests/fixtures only — never in production
| Variable | Default | Purpose |
|---|---|---|
| `TEST_DATABASE_URL` | unset (DB tests skip) | Integration test database |
| `INTEGRATIONS_ALLOW_PRIVATE` | unset | Allows private-range dials (loopback fakes, deliberate LAN deployments) |
| `INTEGRATIONS_ALLOW_INSECURE_IMAP` | unset | Permits plaintext IMAP for fixtures |
| `BASE_URL` / `CHROMIUM_PATH` / `E2E_KEEP_DATA` | see `.env.example` | Browser suites |
## Client test build