perf(docker): stop duplicating the native binary into a second image layer (#2069)

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/<arch>/ /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/<arch>/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 ].
This commit is contained in:
Liam MacPherson authored and GitHub committed 2026-07-31 22:02:59 -05:00
1 parent 0142dc434f
commit 9e90e5cff3
5 files changed
+13 -10

No files matched your search

+1 -1
View File
@@ -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
+5 -2
View File
@@ -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
+5 -2
View File
@@ -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
+1 -3
View File
@@ -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"]
+1 -2
View File
@@ -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