mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
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 ].
66 lines
2.6 KiB
Docker
66 lines
2.6 KiB
Docker
FROM registry.access.redhat.com/ubi9-minimal:9.7
|
|
|
|
ARG VERSION=latest
|
|
# Automatically set by Docker BuildKit to "amd64" or "arm64"
|
|
ARG TARGETARCH
|
|
|
|
ENV FLOCI_VERSION=${VERSION}
|
|
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
|
|
|
|
ENV GOSU_VERSION=1.17
|
|
ENV GOSU_AMD64_SHA256=bbc4136d03ab138b1ad66fa4fc051bafc6cc7ffae632b069a53657279a450de3
|
|
ENV GOSU_ARM64_SHA256=c3805a85d17f4454c23d7059bcb97e1ec1af272b90126e79ed002342de08389b
|
|
RUN set -eux; \
|
|
microdnf install -y --nodocs shadow-utils; \
|
|
microdnf clean all; \
|
|
useradd -r -u 1001 -g root -d /app -s /sbin/nologin floci; \
|
|
arch="$(uname -m)"; \
|
|
case "$arch" in \
|
|
x86_64) gosuArch='amd64'; gosuSha256="$GOSU_AMD64_SHA256" ;; \
|
|
aarch64) gosuArch='arm64'; gosuSha256="$GOSU_ARM64_SHA256" ;; \
|
|
*) echo >&2 "unsupported arch: $arch"; exit 1 ;; \
|
|
esac; \
|
|
curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${gosuArch}"; \
|
|
echo "${gosuSha256} /usr/local/bin/gosu" | sha256sum -c -; \
|
|
chmod +x /usr/local/bin/gosu; \
|
|
gosu --version; \
|
|
gosu nobody true
|
|
|
|
WORKDIR /app
|
|
|
|
RUN mkdir -p /app/data \
|
|
&& chown -R 1001:root /app \
|
|
&& chmod -R g+rwX /app
|
|
|
|
VOLUME /app/data
|
|
|
|
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
|
|
|
|
LABEL org.opencontainers.image.title="Floci" \
|
|
org.opencontainers.image.description="Local AWS emulator — open-source alternative to LocalStack Community" \
|
|
org.opencontainers.image.url="https://floci.io" \
|
|
org.opencontainers.image.source="https://github.com/floci-io/floci" \
|
|
org.opencontainers.image.licenses="MIT" \
|
|
org.opencontainers.image.vendor="Floci" \
|
|
description="Local AWS emulator — open-source alternative to LocalStack Community" \
|
|
io.k8s.description="Local AWS emulator — open-source alternative to LocalStack Community" \
|
|
io.k8s.display-name="Floci" \
|
|
io.openshift.expose-services="4566:tcp" \
|
|
io.openshift.tags="floci aws-emulator" \
|
|
maintainer="Floci <https://github.com/floci-io/floci>" \
|
|
name="floci/floci" \
|
|
summary="Local AWS emulator — open-source alternative to LocalStack Community" \
|
|
url="https://floci.io" \
|
|
vendor="Floci"
|
|
|
|
EXPOSE 4566
|
|
|
|
HEALTHCHECK --interval=5s --timeout=3s --retries=5 \
|
|
CMD curl -f http://localhost:4566/_floci/health || exit 1
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
CMD ["/app/application", "-Dquarkus.http.host=0.0.0.0"]
|