Skip to content

Optimize final image: runtime libs instead of -dev, pin base image - #157

Merged
sethforprivacy merged 1 commit into
mainfrom
optimize-final-image
Jun 23, 2026
Merged

Optimize final image: runtime libs instead of -dev, pin base image#157
sethforprivacy merged 1 commit into
mainfrom
optimize-final-image

Conversation

@sethforprivacy

Copy link
Copy Markdown
Owner

Summary

The final runtime stage was installing full -dev packages (headers, static archives, build-time-only deps) when a runtime image only needs the runtime shared libraries. This swaps them for the runtime-only equivalents, pins the base image, and shallow-clones the source.

Changes

  1. Runtime libs instead of -dev in the final stage. The authoritative list comes from ldd on the built p2pool binary. The direct NEEDED libs map to:

    build -dev package runtime package (Ubuntu 24.04)
    libuv1-dev libuv1t64
    libzmq3-dev libzmq5
    libsodium-dev libsodium23
    libpgm-dev libpgm-5.3-0t64
    libnorm-dev libnorm1t64
    libgss-dev libgssapi-krb5-2
    libcurl4-openssl-dev libcurl4t64
    libidn2-0-dev libidn2-0

    Several packages carry the t64 suffix on Ubuntu 24.04 (noble) due to the 64-bit time_t transition — names were verified against the pinned base, not guessed.

  2. Pin base image ubuntu:latestubuntu:24.04 (both stages) for reproducible builds. Renovate's docker manager will keep it current.

  3. --depth 1 --shallow-submodules on the git clone for a faster, lighter source checkout (verified it still builds with all submodules).

Measured size delta

image size
baseline (ubuntu:latest + -dev) 317 MB
optimized (this PR) 188 MB
delta −129 MB (−41%)

Local verification (native arm64, Apple Silicon)

  • Build succeeds (exit 0), compile parallelism capped, build serialized via lockfile.
  • docker run --rm p2pool:test --help → prints P2Pool v4.17 and full usage (correct smoke test; p2pool needs a monerod to actually mine).
  • ldd /usr/local/bin/p2pool inside the final image → all shared libraries resolve, none "not found" — confirms the runtime-lib swap didn't break the binary.

CI

This touches Dockerfile, so it triggers the Test build of image when Dockerfile is changed workflow on pull_request.

The final runtime stage installed full -dev packages (headers, static
archives, build-time deps) when only the runtime shared libraries are
needed. Replace them with the runtime-only equivalents, verified via
`ldd` on the built p2pool binary against the pinned base.

Changes:
- Final stage: install runtime libs instead of -dev packages
  (libuv1t64, libzmq5, libsodium23, libpgm-5.3-0t64, libnorm1t64,
  libgssapi-krb5-2, libcurl4t64, libidn2-0). Note the t64 names on
  Ubuntu 24.04 due to the 64-bit time_t transition.
- Pin both stages to ubuntu:24.04 (current LTS) instead of
  ubuntu:latest for reproducible builds. Renovate's docker manager
  keeps this current.
- Add --depth 1 --shallow-submodules to the git clone for faster,
  lighter source checkout.

Local verification (native arm64):
- Build succeeds (exit 0).
- `docker run --rm p2pool:test --help` prints "P2Pool v4.17" + usage.
- `ldd` on the binary in the final image: all libs resolve, none missing.
- Image size: 317MB -> 188MB (-129MB, -41%).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sethforprivacy
sethforprivacy marked this pull request as ready for review June 23, 2026 11:10
@sethforprivacy
sethforprivacy merged commit 93b13c1 into main Jun 23, 2026
4 checks passed
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