Skip to content

[UI] ui-new: build the bridge image with cargo-chef on a distroless runtime #2412

Todo

Description

@newfront

Is your feature request related to a problem? Please describe.

The bridge image from #2368 (ui-new/server/Dockerfile) has two costs:

  • Runtime: it runs on debian:bookworm-slim with curl installed for its health check. That carries a shell, apt and curl, none of which the bridge uses; the image is about 170 MB.
  • Build: dependencies are cached with BuildKit cache mounts. Those speed up repeat builds on one machine, but CI layer caches and remote builders don't keep them, so a CI image build would recompile every dependency each time.

Describe the solution you would like

Follow the pattern in the headwaters Dockerfile, which @roeap raised in the #2368 review:

  • Distroless runtime: gcr.io/distroless/cc-debian12:nonroot, pinned by digest. It has the same glibc as the rust:1.88-bookworm build image. The bridge uses rustls with bundled root certificates (reqwest with rustls-tls), so it needs no OpenSSL or system certificates. The base is 9 MB compressed, against 28 MB for bookworm-slim.
  • cargo-chef build: lukemathwalker/cargo-chef:0.1.72-rust-1.88-bookworm, pinned by digest, so the dependencies build in their own cached layer. cargo chef cook replaces build scripts with fn main() {}, so that layer needs neither buf nor proto.

To settle in the change:

  • Health check: distroless has no curl. Either the image drops its HEALTHCHECK, or the bridge gets a self-check mode, as headwaters' healthcheck subcommand does. Once the SPA is served from the bridge ([UI] ui-new: serve the SPA from the bridge image #2413), nothing in Compose waits on the bridge's health.
  • Private registry: CARGO_REGISTRY_URL becomes cargo --config flags today, and cargo chef cook doesn't pass those on. Write the URL to a .cargo/config.toml in the build stage instead: it is a URL, not a secret, and the build stage never reaches the runtime image. The CARGO_CONFIG_FILE secret mount keeps working.
  • User: distroless nonroot is uid 65532, against 10001 today. The bridge mounts no volumes, so nothing depends on the uid.
  • Build time: the release profile (lto = true, codegen-units = 1) makes the final link the slow part of every rebuild, so measure a source-only rebuild before and after.

Additional context

Activity

  1. added this to the 0.9 milestone on Dec 1, 2026
  2. added
    enhancement
    on Dec 1, 2026
  3. self-assigned this
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions