Repository navigation
Todo
Description
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-slimwithcurlinstalled 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 therust:1.88-bookwormbuild image. The bridge uses rustls with bundled root certificates (reqwestwithrustls-tls), so it needs no OpenSSL or system certificates. The base is 9 MB compressed, against 28 MB forbookworm-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 cookreplaces build scripts withfn main() {}, so that layer needs neitherbufnorproto.
To settle in the change:
- Health check: distroless has no
curl. Either the image drops itsHEALTHCHECK, or the bridge gets a self-check mode, as headwaters'healthchecksubcommand 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_URLbecomescargo --configflags today, andcargo chef cookdoesn't pass those on. Write the URL to a.cargo/config.tomlin the build stage instead: it is a URL, not a secret, and the build stage never reaches the runtime image. TheCARGO_CONFIG_FILEsecret mount keeps working. - User: distroless
nonrootis 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
- Review comment: [Docker] Add container environments for ui-new #2368 (comment)
- Both this and [UI] ui-new: serve the SPA from the bridge image #2413 reshape
ui-new/server/Dockerfile, so they can land together.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity