Files
floci/docker/Dockerfile.native
T
TATSUNO “Taz” Yasuhiro 64f06e090f perf(docker): shrink image by 28% using ubi9-micro (109 MB to 78 MB compressed) (#3085)
* perf(docker): move the native image to ubi9-micro

The binary needs only libc, and since #3037 the entrypoint needs only
bash and coreutils. ubi9-micro has both at 7 MB compressed instead of
ubi9-minimal's 40 MB. Measured on arm64 with the nightly-09042026
binary: 109 MB to about 78 MB compressed, 313 MB to 229 MB uncompressed.

ubi9-micro has no useradd and no curl, so the user is one /etc/passwd
line and the healthcheck is a bash /dev/tcp probe. Dockerfile.native
gets the same runtime stage and loses its unused gosu tools stage.
Dockerfile.compat needs microdnf, so it now starts from ubi9-minimal
and copies /app out of the native image.

* chore(docker): share the health probe and split the compat tools stage

The bash health probe is now docker/healthcheck.sh, used by all three
Dockerfiles. Dockerfile.compat gets a version independent tools stage;
the aws CLI shim test and the cache warm job build target: tools, so
they pull no floci image and their cached layers stay stable. ARG
VERSION and the native RUN steps move so only the binary copy changes
between builds.

* fix(docker): copy healthcheck.sh into the compat image from the build context

* ci(compat): build the whole compat image on pull requests and check it starts healthy
2026-09-05 14:46:41 -05:00

40 lines
1.3 KiB
Docker

# Stage 1: Build native executable
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-25 AS build
USER root
WORKDIR /app
# Install Maven 3.9.x (system Maven is too old for Quarkus 3.31)
RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.tar.gz | tar xz -C /opt \
&& ln -sf /opt/apache-maven-3.9.12/bin/mvn /usr/local/bin/mvn
COPY pom.xml .
RUN mvn dependency:go-offline -B
COPY src ./src
RUN mvn clean package -Dnative -DskipTests -B
# Stage 2: Minimal runtime. Same base and user setup as Dockerfile.native-package.
FROM registry.access.redhat.com/ubi9-micro:9.7
WORKDIR /app
RUN echo 'floci:x:1001:0:Floci:/app:/sbin/nologin' >> /etc/passwd \
&& mkdir -p /app/data \
&& chown -R 1001:root /app \
&& chmod -R g+rwX /app
VOLUME /app/data
EXPOSE 4566
HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD ["/usr/local/bin/healthcheck.sh"]
ARG VERSION=latest
ENV FLOCI_VERSION=${VERSION}
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
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/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/app/application"]