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
+126
View File
@@ -0,0 +1,126 @@
# Release: publish the three registry images the federated suite pulls.
#
# Trigger: semver tags WITHOUT a v prefix (the suite's VERSION_RX is
# '^[0-9][0-9\.]*$'), e.g. 1.0.0. Every release pushes:
# federatedcomputer/superbrain-app:<tag> + :latest
# federatedcomputer/superbrain-web:<tag> + :latest
# federatedcomputer/superbrain-migrate:<tag> + :latest
# all three sharing the same version tag (house tooling tracks one version
# per app), for linux/amd64 and linux/arm64.
#
# Required secrets: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN (an access token
# scoped to the federatedcomputer namespace).
#
# The publish job is gated on the smoke job: the migrate image is actually
# bootstrapped against a throwaway PostgreSQL (fresh schema + full ledger +
# idempotent re-run) before anything is pushed, so a broken db/ can never
# reach a tag the upgrade flow will pull.
name: release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: read
jobs:
smoke:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16.15-alpine
env:
POSTGRES_USER: superbrain
POSTGRES_PASSWORD: smoke-only
POSTGRES_DB: superbrain
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U superbrain"
--health-interval 3s
--health-timeout 3s
--health-retries 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Go build + vet + unit tests (DB suites skipped without TEST_DATABASE_URL)
run: |
go build ./internal/... .
go vet ./internal/... .
go test ./internal/...
- name: Build the migrate image
run: docker build -t superbrain-migrate:smoke db/
- name: Bootstrap a fresh database with the image
run: |
docker run --rm --network host \
-e DB_HOST=127.0.0.1 -e PGPASSWORD=smoke-only \
superbrain-migrate:smoke
tables=$(docker run --rm --network host -e PGPASSWORD=smoke-only \
postgres:16.15-alpine psql -h 127.0.0.1 -U superbrain -d superbrain \
-t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema='public'")
ledger=$(docker run --rm --network host -e PGPASSWORD=smoke-only \
postgres:16.15-alpine psql -h 127.0.0.1 -U superbrain -d superbrain \
-t -A -c "SELECT count(*) FROM _migration")
files=$(ls db/migrations/*.sql | wc -l)
echo "tables=$tables ledger=$ledger files=$files"
[ "$tables" -ge 20 ] || { echo "schema.sql did not apply"; exit 1; }
[ "$ledger" = "$files" ] || { echo "ledger incomplete"; exit 1; }
- name: Re-run must be a no-op (idempotency)
run: |
docker run --rm --network host \
-e DB_HOST=127.0.0.1 -e PGPASSWORD=smoke-only \
superbrain-migrate:smoke | grep -q "up to date"
publish:
needs: smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push superbrain-app
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
federatedcomputer/superbrain-app:${{ github.ref_name }}
federatedcomputer/superbrain-app:latest
- name: Push superbrain-web
uses: docker/build-push-action@v6
with:
context: web
file: web/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
federatedcomputer/superbrain-web:${{ github.ref_name }}
federatedcomputer/superbrain-web:latest
- name: Push superbrain-migrate
uses: docker/build-push-action@v6
with:
context: db
file: db/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
federatedcomputer/superbrain-migrate:${{ github.ref_name }}
federatedcomputer/superbrain-migrate:latest