Skip to content

fix(docker): drop unneeded packages from the image stages - #58

Open
lexfrei wants to merge 1 commit into
fix/dependency-advisoriesfrom
fix/runtime-image-packages
Open

lexfrei wants to merge 1 commit into
fix/dependency-advisoriesfrom
fix/runtime-image-packages

Conversation

@lexfrei

@lexfrei lexfrei commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

The image no longer carries build packages it does not need, in either stage.

The final stage installs libssl3 and ca-certificates instead of libssl-dev and libjemalloc-dev. Apart from the C runtime the Debian base already has, OpenSSL is the only shared library the binary loads. jemalloc is built into the binary statically, so ldd shows no jemalloc library. The install also skips recommended packages and removes the apt lists in the same layer.

The builder stage drops libjemalloc-dev too, because tikv-jemalloc-sys compiles jemalloc from source. It also uses apt-get consistently.

I built it for linux/arm64 with both changes. --help runs, and every library in the ldd output inside the image resolves.

The runtime base is still debian:bookworm. debian:bookworm-slim would make the image smaller, but changing the base is out of scope here.

Stacked on #52.

Closes #51

The final stage installed libssl-dev and libjemalloc-dev, which are
build-time packages. The binary needs only the OpenSSL shared library
and CA certificates; jemalloc is linked statically. Install just
libssl3 and ca-certificates there, skip recommended packages and remove
the apt lists to shrink the image and its attack surface.

The builder stage does not need libjemalloc-dev either, because
tikv-jemalloc-sys builds jemalloc from source. Drop it and use
apt-get consistently, as apt is not meant for scripts.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
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