From 6928ca5b23258d372e6352efc3abaa204cca4231 Mon Sep 17 00:00:00 2001 From: Vladimir Babin Date: Tue, 28 Apr 2026 12:48:33 +0300 Subject: [PATCH 1/2] perf(docker): skip make install, copy vizd binary directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `make install` triggers CMake's install-depends-on-all rule, which rebuilds every target in the build graph (cli_wallet, util programs, graphene_wallet, appbase_example, chainbase_test) — including the ones we deliberately skipped via `make -j$(nproc) vizd` in the prior step. Measured cost on warm path: ~3 minutes of redundant compile. The runtime image only invokes /usr/local/bin/vizd (see share/vizd/vizd.sh), so we copy the single binary directly. The multi-stage final image still starts from a clean base, so nothing in /usr/local except vizd matters. Drops the trailing `rm -rf $APPDIR` because the builder stage is discarded in multi-stage; the rm contributed nothing but I/O. Expected impact on PR-warm path: - before: 4m50s (build #18 ~24s + make install #19 ~177s + push) - after: ~1m45s (build #18 ~24s + cp ~0s + push) Cold path saves the same ~3 min for the same reason. --- share/vizd/docker/Dockerfile-production | 9 ++++++--- share/vizd/docker/Dockerfile-testnet | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/share/vizd/docker/Dockerfile-production b/share/vizd/docker/Dockerfile-production index 9021b9196e..67a3a06a2a 100644 --- a/share/vizd/docker/Dockerfile-production +++ b/share/vizd/docker/Dockerfile-production @@ -106,10 +106,13 @@ RUN --mount=type=cache,target=/root/.ccache,id=viz-ccache,sharing=locked \ make -j$(nproc) vizd && \ ccache -s +# `make install` would re-trigger the `all` target through CMake's install-depends-on-all +# rule, rebuilding cli_wallet, util programs, tests, and examples that were deliberately +# skipped by `make -j$(nproc) vizd` above. The runtime image only invokes +# /usr/local/bin/vizd (see share/vizd/vizd.sh), so we copy the single binary directly. +# `rm -rf $APPDIR` is unnecessary because the builder stage is discarded in multi-stage. RUN set -xe ;\ - cd $APPDIR/build ;\ - make install ;\ - rm -rf $APPDIR + cp $APPDIR/build/programs/vizd/vizd /usr/local/bin/vizd # Final cleanup of the builder stage. apt cache mounts above are not affected # by these rm/clean calls because cache mounts are unmounted by the time this diff --git a/share/vizd/docker/Dockerfile-testnet b/share/vizd/docker/Dockerfile-testnet index e1601de7fd..4baca08e74 100644 --- a/share/vizd/docker/Dockerfile-testnet +++ b/share/vizd/docker/Dockerfile-testnet @@ -107,10 +107,13 @@ RUN --mount=type=cache,target=/root/.ccache,id=viz-ccache,sharing=locked \ make -j$(nproc) vizd && \ ccache -s +# `make install` would re-trigger the `all` target through CMake's install-depends-on-all +# rule, rebuilding cli_wallet, util programs, tests, and examples that were deliberately +# skipped by `make -j$(nproc) vizd` above. The runtime image only invokes +# /usr/local/bin/vizd (see share/vizd/vizd.sh), so we copy the single binary directly. +# `rm -rf $APPDIR` is unnecessary because the builder stage is discarded in multi-stage. RUN set -xe ;\ - cd $APPDIR/build ;\ - make install ;\ - rm -rf $APPDIR + cp $APPDIR/build/programs/vizd/vizd /usr/local/bin/vizd # Final cleanup of the builder stage. apt cache mounts above are not affected # by these rm/clean calls because cache mounts are unmounted by the time this From f9463f4c4bdc409c272307ff2543f462b9c05124 Mon Sep 17 00:00:00 2001 From: Vladimir Babin Date: Tue, 28 Apr 2026 14:53:29 +0300 Subject: [PATCH 2/2] perf(docker): tighten multi-stage COPY, drop wasted builder cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two related image-trimming changes: 1) Multi-stage final COPY only brings the vizd binary, not the entire builder /usr/local. The runtime image only invokes /usr/local/bin/vizd (see share/vizd/vizd.sh) and the static link (-DBUILD_SHARED_LIBRARIES=FALSE) means no .so dependencies. The tighter COPY shrinks the runtime layer and the graph exported to GHA layer cache. 2) Drop the trailing builder-stage cleanup RUN (apt-get clean + autoremove + rm -rf). The accompanying comment claimed the step "removes anything that landed in real layers," but the entire builder stage is discarded by multi-stage build — its real layers never reach the runtime image. The step was dead code. Both changes preserve runtime behavior and reduce per-build work. --- share/vizd/docker/Dockerfile-production | 14 +++++--------- share/vizd/docker/Dockerfile-testnet | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/share/vizd/docker/Dockerfile-production b/share/vizd/docker/Dockerfile-production index 67a3a06a2a..7d5ea41269 100644 --- a/share/vizd/docker/Dockerfile-production +++ b/share/vizd/docker/Dockerfile-production @@ -114,16 +114,12 @@ RUN --mount=type=cache,target=/root/.ccache,id=viz-ccache,sharing=locked \ RUN set -xe ;\ cp $APPDIR/build/programs/vizd/vizd /usr/local/bin/vizd -# Final cleanup of the builder stage. apt cache mounts above are not affected -# by these rm/clean calls because cache mounts are unmounted by the time this -# RUN executes; this only removes anything that landed in real layers. -RUN \ - apt-get clean && \ - apt-get autoremove -y && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* - FROM phusion/baseimage:noble-1.0.3 AS production -COPY --from=builder /usr/local /usr/local +# Only the daemon binary is needed at runtime (see share/vizd/vizd.sh). Static link +# (-DBUILD_SHARED_LIBRARIES=FALSE) means no .so dependencies to ship. Copying just +# the binary instead of the entire builder /usr/local shrinks the runtime image and +# the layer graph exported to the GHA layer cache. +COPY --from=builder /usr/local/bin/vizd /usr/local/bin/vizd RUN set -xe ;\ useradd -s /bin/bash -m -d /var/lib/vizd vizd ;\ diff --git a/share/vizd/docker/Dockerfile-testnet b/share/vizd/docker/Dockerfile-testnet index 4baca08e74..783e600ef8 100644 --- a/share/vizd/docker/Dockerfile-testnet +++ b/share/vizd/docker/Dockerfile-testnet @@ -115,16 +115,12 @@ RUN --mount=type=cache,target=/root/.ccache,id=viz-ccache,sharing=locked \ RUN set -xe ;\ cp $APPDIR/build/programs/vizd/vizd /usr/local/bin/vizd -# Final cleanup of the builder stage. apt cache mounts above are not affected -# by these rm/clean calls because cache mounts are unmounted by the time this -# RUN executes; this only removes anything that landed in real layers. -RUN \ - apt-get clean && \ - apt-get autoremove -y && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* - FROM phusion/baseimage:noble-1.0.3 AS production -COPY --from=builder /usr/local /usr/local +# Only the daemon binary is needed at runtime (see share/vizd/vizd.sh). Static link +# (-DBUILD_SHARED_LIBRARIES=FALSE) means no .so dependencies to ship. Copying just +# the binary instead of the entire builder /usr/local shrinks the runtime image and +# the layer graph exported to the GHA layer cache. +COPY --from=builder /usr/local/bin/vizd /usr/local/bin/vizd RUN set -xe ;\ useradd -s /bin/bash -m -d /var/lib/vizd vizd ;\