mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 23:00:59 -05:00
* 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
107 lines
4.9 KiB
Docker
107 lines
4.9 KiB
Docker
ARG VERSION=latest
|
|
# BASE_IMAGE is the image produced by Dockerfile.native-package. Release and nightly
|
|
# tags use VERSION; reusable builds override BASE_IMAGE with the digest-qualified
|
|
# native image they just published.
|
|
#
|
|
# That image is ubi9-micro and has no package manager, so this image cannot extend it.
|
|
ARG BASE_IMAGE=floci/floci:${VERSION}
|
|
FROM ${BASE_IMAGE} AS native
|
|
|
|
# Everything that does not depend on the Floci version. CI builds this stage alone
|
|
# (target: tools) to test the aws CLI shim and to warm the layer cache.
|
|
FROM registry.access.redhat.com/ubi9-minimal:9.7 AS tools
|
|
|
|
LABEL org.opencontainers.image.title="Floci (compat)" \
|
|
org.opencontainers.image.description="Floci compatibility image with AWS CLI and boto3 pre-installed" \
|
|
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="Floci compatibility image with AWS CLI and boto3 pre-installed" \
|
|
io.k8s.description="Floci compatibility image with AWS CLI and boto3 pre-installed" \
|
|
io.k8s.display-name="Floci (compat)" \
|
|
io.openshift.expose-services="4566:tcp" \
|
|
io.openshift.tags="floci aws-emulator" \
|
|
maintainer="Floci <https://github.com/floci-io/floci>" \
|
|
name="floci/floci" \
|
|
summary="Floci compatibility image with AWS CLI and boto3 pre-installed" \
|
|
url="https://floci.io" \
|
|
vendor="Floci"
|
|
|
|
ENV AWS_DEFAULT_REGION=us-east-1
|
|
ENV AWS_ACCESS_KEY_ID=test
|
|
ENV AWS_SECRET_ACCESS_KEY=test
|
|
ENV AWS_ENDPOINT_URL="http://localhost:4566"
|
|
ENV AWS_CONFIG_FILE=/etc/floci/aws/config
|
|
ENV AWS_PAGER=""
|
|
|
|
# AWS CLI v2. v1 (the only version pip3 install awscli can give you) resolves
|
|
# a fixed set of services (SQS, RDS, DocDB, Neptune, EMR, Health) through
|
|
# awscli/customizations/overridesslcommonname.py, which forces the real AWS
|
|
# endpoint whenever no --endpoint-url flag is passed on the command line —
|
|
# no environment variable, including AWS_ENDPOINT_URL and the per-service
|
|
# AWS_ENDPOINT_URL_<SERVICE> overrides, can redirect it (aws/aws-cli#8737).
|
|
# v2 has no equivalent override and resolves every service through the
|
|
# normal endpoint chain, so AWS_ENDPOINT_URL alone is sufficient.
|
|
#
|
|
# v1 also entered maintenance mode 2026-07-15 (EOL 2027-07-15), so this is
|
|
# needed regardless of the endpoint-resolution bug.
|
|
#
|
|
# cli_binary_format has no env var in v2 (its provider chain is config-file,
|
|
# then a base64 constant), so blob params default to base64 here, same as
|
|
# a v2 install against real AWS. A hook passing raw bytes (e.g.
|
|
# aws lambda invoke --payload) needs --cli-binary-format raw-in-base64-out.
|
|
ARG AWSCLI_VERSION=2.36.24
|
|
RUN useradd -r -u 1001 -g root -d /app -s /sbin/nologin floci \
|
|
&& microdnf install -y --nodocs python3 python3-pip unzip \
|
|
&& pip3 install --no-cache-dir boto3 \
|
|
&& case "$(uname -m)" in \
|
|
x86_64) arch=x86_64 ;; \
|
|
aarch64) arch=aarch64 ;; \
|
|
*) echo "unsupported arch: $(uname -m)" >&2; exit 1 ;; \
|
|
esac \
|
|
&& curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${arch}-${AWSCLI_VERSION}.zip" -o /tmp/awscliv2.zip \
|
|
&& unzip -q /tmp/awscliv2.zip -d /tmp \
|
|
&& /tmp/aws/install --bin-dir /usr/bin --install-dir /usr/local/aws-cli \
|
|
&& rm -rf /tmp/awscliv2.zip /tmp/aws \
|
|
&& microdnf remove -y unzip \
|
|
&& microdnf clean all \
|
|
&& rm -rf /root/.cache/pip
|
|
|
|
COPY bin/awslocal /usr/local/bin/awslocal
|
|
RUN chmod +x /usr/local/bin/awslocal
|
|
|
|
# Pre-create the init-hook directories so archive-based copies (Testcontainers
|
|
# withCopyFileToContainer / `docker cp`) can drop hooks straight into them.
|
|
# Docker's archive extract unpacks into an existing dir and never mkdir -p's the
|
|
# parents, so without these the copy fails. Mirrors LocalStack, which ships
|
|
# /etc/localstack/init. Owned by the runtime user (uid 1001, group root).
|
|
RUN mkdir -p /etc/localstack/init/boot.d /etc/localstack/init/start.d /etc/localstack/init/ready.d \
|
|
/etc/floci/init/boot.d /etc/floci/init/start.d /etc/floci/init/ready.d \
|
|
&& chown -R 1001:root /etc/localstack /etc/floci
|
|
|
|
WORKDIR /app
|
|
# A chmod after the copy below would rewrite the 200 MB binary into a second layer.
|
|
RUN chown 1001:root /app && chmod g+rwX /app
|
|
|
|
FROM tools
|
|
|
|
ARG VERSION
|
|
ENV FLOCI_VERSION=${VERSION}
|
|
ENV FLOCI_STORAGE_PERSISTENT_PATH=/app/data
|
|
|
|
COPY --from=native --chown=1001:root /app/ /app/
|
|
VOLUME /app/data
|
|
|
|
COPY --from=native /usr/local/bin/docker-entrypoint.sh /usr/local/bin/localstack-parity.sh /usr/local/bin/
|
|
# From the build context, not the native image: a published native image may predate the script.
|
|
COPY --chmod=755 docker/healthcheck.sh /usr/local/bin/
|
|
|
|
EXPOSE 4566
|
|
|
|
HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD ["/usr/local/bin/healthcheck.sh"]
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
CMD ["/app/application", "-Dquarkus.http.host=0.0.0.0"]
|
|
|
|
USER 1001 |