fix(docker): produce a working native image from Dockerfile.native (#3325)

* fix(docker): build the native image on arm64

Dockerfile.native compiles inside the Mandrel builder image and passed no
extra build arguments, so on arm64 the compile stage ended with
BranchTargetOutOfBoundsException. It was the only native build left in the
repository without -H:-AOTSingleCallsiteInline; the workflow native builds
have passed it since #3175.

That option inlines a method reached from exactly one call site whatever its
size. Each Query handler is reached from one switch case, each switch from one
handle(), and each handle() from the single AwsQueryController.dispatch call
site, so the generated REST invoker for dispatch grows to about 1.2 MB. An
aarch64 conditional branch reaches 1 MB and the aarch64 backend has no long
branch fallback, so the branch cannot be encoded. x86_64 reaches 2 GB, which
is why amd64 builds.

* fix(docker): copy libz into the native image so the runner starts

The builder image carries zlib as a shared library only, so native-image
links zlib dynamically and the runner needs libz.so.1 at run time. The
ubi9-micro runtime base does not ship it, so the image built from this
Dockerfile exited at once with "error while loading shared libraries:
libz.so.1". The build stage now copies the library across.

This is not architecture specific; amd64 has the same gap. The published
images are unaffected: their binaries are compiled on the CI runners, where
zlib is available as a static library and is compiled into the binary.
This commit is contained in:
Mario Toffia authored and GitHub committed 2026-09-09 18:19:15 -05:00
1 parent dde11aeb6a
commit a501eabbf9
1 file changed
+11 -1
+11 -1
View File
@@ -11,7 +11,14 @@ COPY pom.xml .
RUN mvn dependency:go-offline -B
COPY src ./src
RUN mvn clean package -Dnative -DskipTests -B
# Quarkus 3.39 switches on -H:+AOTSingleCallsiteInline for Mandrel 25.0.4+. The generated
# REST invokers for AwsQueryController.dispatch and AwsJson11Controller.handle are each the
# single call site of a very large method; inlined, the method outgrows the aarch64
# conditional-branch range and the build dies with BranchTargetOutOfBoundsException.
# The flag only exists on Mandrel, so it is passed here rather than in application.yml,
# the same way the workflow native builds pass it.
RUN mvn clean package -Dnative -DskipTests -B \
-Dquarkus.native.additional-build-args-append=-H:-AOTSingleCallsiteInline
# Stage 2: Minimal runtime. Same base and user setup as Dockerfile.native-package.
FROM registry.access.redhat.com/ubi9-micro:9.7
@@ -31,6 +38,9 @@ ARG VERSION=latest
ENV FLOCI_VERSION=${VERSION}
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
# The builder image has no zlib-static, so native-image links zlib dynamically and the
# runner needs libz.so.1, which ubi9-micro does not ship. Take it from the builder image.
COPY --from=build /usr/lib64/libz.so.1 /usr/lib64/libz.so.1
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 docker/healthcheck.sh /usr/local/bin/