Skip to content

Commit 749614f

Browse files
committed
fix(docker): add libz.so.1 to runtime image
The Chainguard glibc-dynamic runtime introduced in 8b520a8 ships only glibc + libgcc + ca-certs + tzdata. nodedb's binary dynamically links libz.so.1 (transitively via crates that default to system zlib, e.g. flate2 with its default `zlib` feature), causing immediate startup failure on the v0.1.0 image: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory This patch copies libz from the Debian builder stage into /usr/lib of the runtime, where the dynamic linker finds it via the default search path. The source path glob covers both amd64 and arm64 multiarch layouts — only the building arch's directory exists per matrix job. Long-term cleanup options (any of which would let us drop this COPY): * Switch flate2 (and any other zlib-using deps) to `rust_backend`, making libz a build-time C lib statically linked into the binary. * Or vendor libz via the `libz-sys` `static` feature. * Or move runtime to `cgr.dev/chainguard/wolfi-base` + `apk add zlib`. Reproducer (with v0.1.0 image): docker run --rm farhansyah/nodedb:0.1.0
1 parent 1d13629 commit 749614f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ USER nonroot:nonroot
4545

4646
COPY --from=builder --chown=nonroot:nonroot /build/target/release/nodedb /usr/local/bin/nodedb
4747

48+
# nodedb dynamically links libz.so.1 (transitively via crates that default to
49+
# system zlib — e.g. flate2 with its default `zlib` feature). Chainguard's
50+
# glibc-dynamic ships only glibc + libgcc + ca-certs + tzdata, so the runtime
51+
# fails immediately with: "error while loading shared libraries: libz.so.1:
52+
# cannot open shared object file: No such file or directory".
53+
#
54+
# Copy the Debian builder's libz into a default ld.so search path. The glob
55+
# covers both amd64 and arm64 — per-arch builds only see their own multiarch
56+
# directory, so exactly one match per build.
57+
#
58+
# Long-term cleanup options (any of these would let us drop this COPY):
59+
# * Switch flate2 (and any other zlib-using deps) to the `rust_backend`
60+
# feature so libz becomes a build-time C lib statically linked.
61+
# * Or vendor libz via the `libz-sys` `static` feature.
62+
# * Or move runtime to `cgr.dev/chainguard/wolfi-base` + `apk add zlib`.
63+
COPY --from=builder /lib/*-linux-gnu/libz.so.1 /usr/lib/libz.so.1
64+
4865
# Bind to all interfaces (required for Docker port mapping)
4966
# Point data dir at the declared volume
5067
ENV NODEDB_HOST=0.0.0.0 \

0 commit comments

Comments
 (0)