Skip to content

feat: ship fabriq-admin as a runtime-configured container image - #1

Merged
juicycleff merged 7 commits into
mainfrom
container-image
Oct 22, 2026
Merged

juicycleff merged 7 commits into
mainfrom
container-image

Conversation

@juicycleff

@juicycleff juicycleff commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The console now ships as a container image you configure at start, not at build time. One image works on any host and under any URL prefix, which is what Loomplane needs to offer a hosted Fabriq with its admin console in one click.

docker run --rm -p 8080:8080 \
  -e FABRIQ_ADMIN_UPSTREAM=http://fabriq:8081 \
  -e FABRIQ_ADMIN_UPSTREAM_KEY=fq_... \
  -e FABRIQ_ADMIN_BASE_PATH=/console/ \
  -e FABRIQ_ADMIN_DEFAULT_TENANT=acme \
  ghcr.io/xraph/fabriq-admin:0.1.0

What changed

  • readRuntimeConfig() in admin-sdk reads window.__FABRIQ_ADMIN_CONFIG__ from a config.js the container writes, then falls back to the VITE_* env and the old defaults. A relative apiUrl is resolved against the page, so /console/admin works behind a prefix. A dsn on the window object is ignored, so a key can't end up in a served file.
  • The host gets <base href="/">, base: "./" in Vite and a config.js placeholder. The router mounts at the runtime base path, and FABRIQ_ADMIN_DEFAULT_TENANT preselects a tenant when the browser has none.
  • listTenants reads the { tenants } envelope the server actually returns. It was reading items and always coming back empty.
  • New image on nginxinc/nginx-unprivileged:1.27-alpine, port 8080, uid 101, /healthz. Only /tmp has to be writable, so a read-only root filesystem works. The entrypoint script validates every env value and exits 1 before nginx starts if anything is off (quotes, semicolons, spaces, newlines, . segments and so on).
  • With FABRIQ_ADMIN_UPSTREAM set, /admin/ is proxied to the Fabriq server with buffering off, so SSE streams work. With a key set, the proxy adds Authorization: Bearer and overrides whatever the browser sent. It also drops the browser's Cookie header, lifts nginx's 1 MB body limit (file uploads are base64 JSON), and returns 403 to cross-site and same-site browser requests, since the injected key turns /admin/ into an ambient credential.
  • CI now runs through the shared xraph/workflows node-ci.yml@v1 (test, then build) and gets an image job running the entrypoint tests and a Docker smoke test. The check names change to ci / Check (node 24) and Container image.
  • release.yml publishes the npm packages through npm-publish.yml@v1 after a CI gate: all 25 packages in dependency order, next for pre-release tags, provenance on. Its image job pushes ghcr.io/xraph/fabriq-admin:<version> for amd64 and arm64, plus :<major>.<minor> for stable versions. The README has a "Run the container" section.

Things you should know

The upstream hostname is resolved once, when the container starts. If it doesn't resolve then, the container exits. If the Fabriq container is recreated with a new IP, restart the console. On Kubernetes, point it at a Service and this never comes up.

When a key is injected, the console doesn't ask for a login, so anyone who can reach it gets that key's rights. Keep it behind an authenticated proxy and never route it publicly.

How we checked it

  • pnpm test: 598 tests pass. pnpm -r build is clean.
  • sh deploy/docker/entrypoint_test.sh: 74 pass, including every injection character on the key, upstream and base path.
  • sh deploy/docker/smoke.sh: smoke: ok. It runs the image read-only as uid 101 against an echo upstream and checks key injection, cookie stripping, the 403s, base path rewriting on deep links, cache headers and exit 1 on bad env.
  • docker buildx build --platform linux/amd64,linux/arm64 builds both.
  • actionlint on both workflows: clean.
  • We also loaded the image in a browser behind a /console/ prefix-stripping nginx. Every asset and federation chunk loads, and the upstream sees /admin/... with the injected key and X-Tenant-ID. That run is how we caught the relative apiUrl being applied twice, which the fix commit covers with a test.

…sh workflow

The npm job ran its own install, build, test, stamp and `pnpm -r publish` steps. It now gates on the shared node-ci workflow and publishes through npm-publish.yml@v1 with an explicit, dependency-ordered package list, `next` for pre-release tags, provenance, and skip-existing so a half-finished release can be resumed. The image job is unchanged.
@juicycleff
juicycleff merged commit 779c318 into main Oct 22, 2026
2 checks passed
@juicycleff
juicycleff deleted the container-image branch October 22, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant