From 9e90e5cff3b312af559506fd8d9b97750c91e0d9 Mon Sep 17 00:00:00 2001 From: Liam MacPherson <11508628+LiamMacP@users.noreply.github.com> Date: Sat, 1 Aug 2026 04:02:59 +0100 Subject: [PATCH] perf(docker): stop duplicating the native binary into a second image layer (#2069) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both native Dockerfiles wrote the ~196 MB binary into the image twice. A RUN that renames or chmods a large file rewrites the whole file into a new layer, so the published image carried two copies of it: 110 MB ubi9-minimal base 18.8 MB microdnf install 196 MB COPY --chown=1001:root native// /app/ 196 MB RUN mv /app/*-runner /app/application && chmod +x /app/application Set the mode in the COPY itself and move the rename out of the image and into the build pipeline, which now stages the binary as native//application. Dockerfile.native does the same with a single COPY --chmod=755 --from=build. Measured on linux/arm64 against floci/floci:1.5.34, with a 196 MB binary on both sides so the comparison is like for like: uncompressed 521 MB -> 325 MB compressed 168 MB -> 104 MB (sum of gzip -6 layer blobs; Docker Hub reports 166.1 MB for 1.5.34) layers 8 -> 6 No behaviour change. The only filesystem difference in the resulting image is quarkus-artifact.properties, now 0755 rather than 0644, because --chmod applies to every file in the staged directory. /app and /app/data keep 0775 and uid 1001:0 for arbitrary-uid (OpenShift) runs, and /app/application keeps 0755 — docker/entrypoint.sh gates its default command on [ -x /app/application ]. --- .github/workflows/compatibility.yml | 2 +- .github/workflows/nightly.yml | 7 +++++-- .github/workflows/release.yml | 7 +++++-- docker/Dockerfile.native | 4 +--- docker/Dockerfile.native-package | 3 +-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index fe6764cf96..5044b0d741 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -39,7 +39,7 @@ jobs: - name: Stage native binary for packaging run: | mkdir -p native/arm64 - cp target/*-runner native/arm64/ + cp target/*-runner native/arm64/application # include any sidecar .so the runtime image may need (matches nightly artifact set) cp target/*.so native/arm64/ 2>/dev/null || true diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ecc61cdae7..2107bfa58a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -130,8 +130,11 @@ jobs: name: native-arm64 path: native/arm64/ - - name: Make binaries executable - run: chmod +x native/amd64/*-runner native/arm64/*-runner + - name: Stage binaries under a fixed name + run: | + for arch in amd64 arm64; do + mv native/$arch/*-runner native/$arch/application + done - name: Set created timestamp id: created diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5341e79ec3..b459c8e649 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,8 +116,11 @@ jobs: name: native-arm64 path: native/arm64/ - - name: Make binaries executable - run: chmod +x native/amd64/*-runner native/arm64/*-runner + - name: Stage binaries under a fixed name + run: | + for arch in amd64 arm64; do + mv native/$arch/*-runner native/$arch/application + done - uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 diff --git a/docker/Dockerfile.native b/docker/Dockerfile.native index 44629b75da..3bf583b110 100644 --- a/docker/Dockerfile.native +++ b/docker/Dockerfile.native @@ -63,11 +63,9 @@ ARG VERSION=latest ENV FLOCI_VERSION=${VERSION} ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data -COPY --from=build /app/target/*-runner /app/application +COPY --chmod=755 --from=build /app/target/*-runner /app/application COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY --chmod=755 docker/localstack-parity.sh /usr/local/bin/localstack-parity.sh -RUN chmod +x /app/application - ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] CMD ["/app/application"] diff --git a/docker/Dockerfile.native-package b/docker/Dockerfile.native-package index d6527936fc..6255a716c3 100644 --- a/docker/Dockerfile.native-package +++ b/docker/Dockerfile.native-package @@ -34,8 +34,7 @@ RUN mkdir -p /app/data \ VOLUME /app/data -COPY --chown=1001:root native/${TARGETARCH}/ /app/ -RUN mv /app/*-runner /app/application && chmod +x /app/application +COPY --chmod=755 --chown=1001:root native/${TARGETARCH}/ /app/ COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY --chmod=755 docker/localstack-parity.sh /usr/local/bin/localstack-parity.sh