Files
floci/docker/Dockerfile
T
Hector Ventura b0a8dff206 perf(docker): drop the gosu layer and two no-op native-image inputs (#3037)
The native image's tools layer installed shadow-utils, which ubi9-minimal
9.7 already ships, and downloaded a gosu binary: 19 MB on disk, 3.66 MB
compressed, byte-identical on every release since 1.5.34. The entrypoint
still starts as root and still grants the bind-mounted Docker socket's
group to the floci user, but through coreutils, which the base image has:
`chroot --userspec=1001:0 --groups=0,<socket gid> --skip-chdir /` drops to
uid 1001 with the socket's gid as a supplementary group. The group is
passed by number, so no /etc/group entry is needed, and --skip-chdir keeps
/app as the working directory where the relative ./data paths resolve. The
layer is now 24.6 kB (one useradd). The JVM Dockerfile drops its gosu
download too: the entrypoint is shared, so once it execs chroot nothing
there calls gosu. Floci's release and nightly pipelines never publish that
image; build-images.yml is a reusable workflow a fork invokes to publish its
own copy, and its noble base carries the same coreutils chroot flags.

Two inputs to the native build go with it, neither changing a byte:
--allow-incomplete-classpath and --report-unsupported-elements-at-runtime
have been no-ops since GraalVM 22.1 (Quarkus passes --link-at-build-time
itself, so a missing reachable class already fails the build), and the
brotli4j platform JNI jars are excluded from quarkus-rest-jackson because
Floci never enables Brotli compression and the jar was never embedded
(resource count unchanged at 197). A native build without them produces
the same 232.25 MB image and the same reachable set.

Verified on the arm64 image: uid=1001 gid=0; a socket owned by gid 999
yields groups=0,999 end to end; /app/data writable; argv fallthrough
intact; sdk-test-java compat suite 1,667/1,667 against the native image
with the socket mounted.
2026-09-04 22:30:28 -04:00

85 lines
2.5 KiB
Docker

# Stage 1: Build
FROM eclipse-temurin:25-jdk-noble AS build
WORKDIR /build
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
COPY pom.xml .
RUN mvn dependency:go-offline -q
COPY src/ src/
RUN mvn clean package -DskipTests -q
# Stage 2: Runtime
FROM eclipse-temurin:25-jre-noble
ARG VERSION=latest
ENV FLOCI_VERSION=${VERSION}
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
ENV AWS_DEFAULT_REGION=us-east-1
ENV AWS_ACCESS_KEY_ID=test
ENV AWS_SECRET_ACCESS_KEY=test
ENV AWS_CONFIG_FILE=/etc/floci/aws/config
# Privilege drop happens in the entrypoint through coreutils chroot, so no gosu
# download; wget stays for the HEALTHCHECK below.
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates passwd python3 python3-pip wget; \
rm -rf /var/lib/apt/lists/*; \
pip3 install --no-cache-dir --break-system-packages awscli boto3; \
aws_bin="$(command -v aws)"; \
mv "$aws_bin" /usr/bin/aws.real; \
printf '#!/bin/sh\nexec /usr/bin/aws.real --endpoint-url=http://localhost:4566 "$@"\n' > /usr/bin/aws; \
chmod +x /usr/bin/aws; \
useradd -r -u 1001 -g root -d /app -s /sbin/nologin floci
WORKDIR /app
RUN mkdir -p /app/data /etc/floci/aws \
&& printf '[default]\nendpoint_url = http://localhost:4566\n' > /etc/floci/aws/config \
&& chown 1001:root /app \
&& chmod "g+rwX" /app \
&& chown 1001:root /app/data
COPY --from=build /build/target/quarkus-app/ quarkus-app/
RUN chown -R 1001:root /app/quarkus-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
VOLUME /app/data
EXPOSE 4566
# Need to expose separately due to https://github.com/floci-io/floci/issues/2095.
# This preseres compatibility with https://github.com/docker-java/docker-java/blob/002b6eb7aa2b892be729c7c2a5e95f782924db38/docker-java-api/src/main/java/com/github/dockerjava/api/model/ExposedPort.java#L119
EXPOSE 6379
EXPOSE 6380
EXPOSE 6381
EXPOSE 6382
EXPOSE 6383
EXPOSE 6384
EXPOSE 6385
EXPOSE 6386
EXPOSE 6387
EXPOSE 6388
EXPOSE 6389
EXPOSE 6390
EXPOSE 6391
EXPOSE 6392
EXPOSE 6393
EXPOSE 6394
EXPOSE 6395
EXPOSE 6396
EXPOSE 6397
EXPOSE 6398
EXPOSE 6399
HEALTHCHECK --interval=5s --timeout=3s --retries=5 \
CMD wget -q --spider http://localhost:4566/_floci/health || exit 1
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["java", "--enable-native-access=ALL-UNNAMED", "-jar", "/app/quarkus-app/quarkus-run.jar"]