fix: switch final stage to debian-slim so file caps survive Kaniko #60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/debian-slim-final-stage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #54 (properly this time).
Background
The v2.1.8+rs.1 retag actually built and pushed successfully after #59, so the registry has
code.rly.best/gofix/portal-tunnel-rs:v2.1.8-rs.1. Pulling and inspecting the binary inside that image:No file caps. #55's capstamp pattern preserves caps under BuildKit (which is what I verified locally) but Kaniko strips the
security.capabilityxattr from every cross-stage COPY, with or without--chown. The fix in #55 was real for BuildKit-based pipelines but didn't actually fix the published Kaniko-built image.Fix
Give up on the distroless final stage and use
debian:bookworm-slim. Runsetcapdirectly in the final stage so there is no cross-stage COPY of the cap-bearing binary, and Kaniko has no opportunity to drop the xattr.Diff:
gcr.io/distroless/cc-debian12:nonroot, drop thecapstampintermediate stage.debian:bookworm-slim+apt-get install -y ca-certificates libcap2-bin.useradd.COPY --from=buildbrings in the binary and/portal-certsdirectory.RUN setcap ... && chown -R 65532:65532 /portal-certsapplies caps in-stage.Image size goes from ~50 MiB (distroless) to ~80 MiB. Acceptable for the relay's deployment.
Validation
Local Rust CI matrix:
cargo fmt --checkcleancargo test --locked86 passed, 3 ignoredcargo clippy --locked --all-targets -- -D warningscleanAfter merge, retag
v2.1.8+rs.1(currently in draft) on the new HEAD, watch the workflow, pull the registry image, verifygetcapreturns the expected caps, redeploy rly.best from the registry image. Promote the Forgejo Release back from draft to published only after that end-to-end passes.