Skip to content

feat(docker): run the dashboard and the server as separate hardened containers - #6

Merged
TheMeinerLP merged 5 commits into
mainfrom
feat/split-containers
Aug 7, 2026
Merged

TheMeinerLP merged 5 commits into
mainfrom
feat/split-containers

Conversation

@TheMeinerLP

@TheMeinerLP TheMeinerLP commented Aug 7, 2026 •

Copy link
Copy Markdown

The dashboard and the server shipped as one container. This adds a second image so they can
run apart, hardened, without taking anything away from the bundled deployment.

The bundled setup stays the default and stays the same build. The guide leads with when
not to split: two images and a proxy hop are a real cost.

The problem that had to be solved first

The dashboard could only be configured by the server that served it. The server rewrites
{{REPOSILITE.*}} placeholders in the assets on their way to the browser, and the settings
API that would otherwise carry those values is managerOnly. Anything else serving the same
files hands the browser raw tokens and no way to resolve them.

So GET /api/frontend/settings now publishes them, keyed by the same tokens. Both paths read
one map, so a bundled dashboard and a detached one cannot drift, and a plugin that registers
a placeholder reaches both without knowing which is in use.

It is anonymous deliberately: every value in it is already handed to any unauthenticated
visitor of the bundled dashboard, spliced into the index page and the script bundle before
they are served. /api/settings stays authenticated, since it exposes the whole
configuration including the LDAP search password.

The dashboard detects which mode it is in from the placeholders themselves and fetches only
when they arrived unsubstituted.

Two things only a running container revealed

The base path must be baked in at build time. The asset URLs live in script tags that the
browser resolves before any of our code runs, so no runtime fetch can fix them. Without this
the app never boots in split mode. INGOT_BASE_PATH now overrides the placeholder.

The tmpfs mounts need the image's uid. nginx renders its config into /etc/nginx/conf.d
at startup. Mounted without uid=101,gid=101 it lands owned by root, nginx cannot write, and
it starts with no server block at all rather than failing. The symptom is a container that
reports healthy and refuses every connection.

Both are in the compose file and called out in the guide.

Hardening

Dashboard Server
User non-root (uid 101, in the image) non-root (uid 977, in the image)
Root filesystem read only writable, it stores artifacts
Capabilities all dropped all dropped
no-new-privileges yes yes
Base image pinned by digest pinned by digest
Published port yes, the only one none, reached through the proxy

The server previously relied on its entrypoint to drop privileges; it now has a non-root
USER so unprivileged is the default. The root path stays for deployments that set PUID
or PGID.

node_modules and build output are excluded from the build context. A host checkout would
otherwise ship its own into the image on top of what the build installed, and they are not
interchangeable: these images build on alpine, so anything with a native component would be
the wrong binary.

Why proxying, not two origins

The dashboard routes on the URL hash, so the browser only ever asks its container for the
document root, /assets/ and the favicon. Everything else is proxied. That direction is
deliberate: repository names are arbitrary top-level paths and cannot be told from dashboard
routes by prefix. Keeping one origin also avoids CORS on every repository read, not just on
the API.

Verified

Not just built. Both containers were run together, the dashboard read only with all
capabilities dropped, and checked in a browser:

  • the dashboard loads and lists the repositories the server returned through the proxy
  • /api/frontend/settings is fetched over the network, and the rendered organisation link is
    the value it returned rather than the location-derived fallback
  • bundled mode is unchanged: assets carry no unsubstituted tokens and no settings request is
    made at all
  • with INGOT_LOCAL_DEFAULTFRONTEND=false the server no longer answers with a dashboard; what
    remains is the 1.4 KB operator-replaceable landing page, which the proxy never reaches
  • the server is not reachable except through the dashboard
  • backend unit and integration suites pass

CI now builds both images, and starts one

Neither image was built outside a release, so a Dockerfile that no longer works would have
been discovered with a tag already pushed. Adding a second image made that gap worse, so
both are built on every pull request. Nothing is pushed; the release job stays the only
thing that publishes.

The dashboard is also started, because building it proves only that the Dockerfile
parses. Both of the real bugs in this image failed at runtime and would have sailed through
a build:

  • nginx rendering no server block, so the container reports healthy and answers nothing
  • asset URLs that never resolve, so the page loads and the app never starts

The check reads index.html, refuses any surviving placeholder, then follows the bundle the
page actually asks for rather than assuming its name.

Verified against a deliberately broken image built without the base path fix: the check fails
on it and names VITE_BASE_PATH, the placeholder whose absence breaks the app outright.

Rebased onto current main after #5 merged, so the Trivy gate and this branch coexist rather
than colliding on the same insertion point in ci.yml.

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Test results

 68 files   68 suites   10m 13s ⏱️
325 tests 324 ✅ 1 💤 0 ❌
327 runs  326 ✅ 1 💤 0 ❌

Results for commit 849c087.

♻️ This comment has been updated with latest results.

A dashboard running outside this process cannot configure itself. The values it
needs are substituted into the assets as they are served, and the settings API
that would otherwise carry them is managerOnly, so a separate container has
nowhere to read its own title or base path from.

GET /api/frontend/settings returns them, keyed by the same placeholder tokens
the substitution uses. Both paths now read one map, so a bundled dashboard and a
detached one cannot drift, and a plugin that registers a placeholder reaches
both without knowing which is in use.

The endpoint is anonymous on purpose. Every value in it is already handed to any
unauthenticated visitor of the bundled dashboard, spliced into the index page
and the script bundle before they are served, so publishing them under a URL
discloses nothing that was not public already. /api/settings stays authenticated:
it exposes the whole configuration, LDAP search password included.

Verified against a running instance: the endpoint answers 200 without
credentials, its values match the served index page, and the javadoc plugin's
placeholder appears without that plugin knowing about any of this.
…stituted

The dashboard could only be configured by the server that served it, which
rewrites the placeholders on their way to the browser. Anything else serving the
same files hands the browser the raw tokens.

The placeholders now say which mode applies. A token that still names itself was
never substituted, so the settings are fetched from the server instead. Served
by the server, nothing is fetched and behaviour is exactly as before.

Two details that are easy to get wrong:

Only the arguments to read() may spell a placeholder out. A table of fallbacks
keyed by the full token would be rewritten by the substitution as well, so the
fallbacks are keyed by the bare name, which nothing rewrites.

The API client used to capture the base url at import, which happens while the
settings are still in flight. It now reads per call, otherwise a deployment
mounted under a sub path would keep talking to the wrong prefix.

The development stub serves the endpoint too, so running the dashboard against
it exercises the fetch path rather than only the fallbacks.

Verified both ways in a browser. Detached, the rendered organisation link is the
one the endpoint returned rather than the location derived fallback. Bundled, the
served assets carry no unsubstituted tokens and no request for the settings is
made at all.
The dashboard and the server shipped as one container, so the dashboard could
not be scaled or restarted on its own, and every byte of static content was
served by a JVM.

The dashboard image is nginx-unprivileged: it already runs as a non-root user
and listens above 1024 rather than starting as root to drop privileges later. It
holds no writable state, so it runs with a read only root filesystem given
tmpfs for the paths nginx writes. Both bases are pinned by digest as well as
tag, so a rebuild cannot land somewhere else.

Routing works because the dashboard routes on the hash. The browser only ever
asks this container for the document root, the hashed assets and the favicon, so
everything else is proxied. That direction matters: repository paths are
arbitrary top level names and cannot be told from dashboard routes by prefix.
Proxying rather than pointing the browser at the server keeps one origin, which
avoids CORS on every repository read.

Two things only a running container revealed. The base path has to be baked in
at build time, because the asset URLs sit in script tags that must resolve
before any of our code runs, so INGOT_BASE_PATH now overrides the placeholder.
And the placeholders left in the document head are replaced during the build,
since the head renders before the app can fetch anything and would otherwise
show a raw token in the browser tab.

The server image gets the same treatment: digests pinned, and a non-root USER so
the default is unprivileged instead of relying on the entrypoint to drop. The
root path stays for deployments that set PUID or PGID.

node_modules and build output are excluded from the context. A host checkout
would otherwise ship its own into the image on top of what the build installed,
and the two are not interchangeable: these images build on alpine, so anything
with a native component would be the wrong binary.

Verified end to end with both containers running, the dashboard read only and
with all capabilities dropped: the dashboard loads, fetches its settings through
the proxy, and lists the repositories the server returned.
Adds the compose file for the split, publishes the dashboard image alongside the
server one at the same version, and writes down when the split is worth taking.

Only the dashboard publishes a port. The server sits on the internal network and
is reached through the proxy, which is also what keeps both on one origin so no
repository read needs CORS. Publishing a port for the server would bypass the
proxy along with everything configured on it, so the compose file says so rather
than leaving it to be discovered.

Both services drop all capabilities and run unprivileged. The dashboard runs
read only, given tmpfs for the paths nginx writes. Those mounts carry the image's
uid on purpose: without it they land owned by root, nginx cannot render its
configuration into conf.d, and it starts with no server block at all rather than
failing. The symptom is a container that reports healthy and refuses every
connection, which is a bad afternoon to debug from scratch.

The server is not read only, because it writes artifacts, logs and a database.
What it gets is an unprivileged default user, which is the part that matters.

The guide leads with when not to do this. Two images and a proxy hop are a real
cost, and the bundled dashboard is the same build, not a lesser one.
Neither image was built outside a release, so a Dockerfile that no longer works
would be discovered with a tag already pushed. That gap mattered more once a
second image existed.

Both are now built on every pull request, and nothing is pushed: the release job
stays the only thing that publishes.

The dashboard is also started, because building it proves only that the
Dockerfile parses. Both of the real bugs this image had failed at runtime and
would have passed a build: nginx rendering no server block, so the container
reports healthy and answers nothing, and asset URLs that never resolve, so the
page loads and the app never starts. The check reads index.html, refuses any
surviving placeholder, then follows the bundle the page actually asks for rather
than assuming its name.

Verified against a deliberately broken image, built without the base path fix:
the check fails on it and names VITE_BASE_PATH, which is the placeholder whose
absence breaks the app outright.

Also points the Docker and Kubernetes guides at the split, since a reader
deciding how to deploy meets those first.
@TheMeinerLP
TheMeinerLP force-pushed the feat/split-containers branch from 60d9dfc to 849c087 Compare August 7, 2026 18:46
@TheMeinerLP
TheMeinerLP merged commit f7bff49 into main Aug 7, 2026
8 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/split-containers branch August 7, 2026 18:59
@github-actions github-actions Bot mentioned this pull request Aug 7, 2026
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