From 7319f0352f7e5abb88dd36534377d00d054441da Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Wed, 19 Mar 2025 15:13:25 +0100 Subject: [PATCH] Dockerfile: optimize layers Squashed some layers to reduce the amount of layers in the image. Also rearranged some layers to reduce the amount of layers that have to be rebuild. If one layer changes all layers after have to be updated. By moving the ones least likely to change first this means less layers have to be rebuild, pushed and pulled on new releases. Signed-off-by: Marco Franssen --- dockerfiles/Dockerfile | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 881dbd7c454..297ae583043 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -24,16 +24,15 @@ FROM debian:bookworm-slim AS builder-base COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ -ARG FLB_NIGHTLY_BUILD -ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD +ARG FLB_NIGHTLY_BUILD \ + FLB_CHUNK_TRACE=On -ARG FLB_CHUNK_TRACE=On -ENV FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE} +ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD \ + FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE} \ + DEBIAN_FRONTEND=noninteractive RUN mkdir -p /fluent-bit/bin /fluent-bit/etc /fluent-bit/log -ENV DEBIAN_FRONTEND=noninteractive - # hadolint ignore=DL3008 RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ apt-get update && \ @@ -68,8 +67,9 @@ FROM builder-base AS builder WORKDIR /src/fluent-bit/build/ # Required to be set to ARMV7 for that target -ARG WAMR_BUILD_TARGET -ARG EXTRA_CMAKE_FLAGS +ARG WAMR_BUILD_TARGET \ + EXTRA_CMAKE_FLAGS + ENV EXTRA_CMAKE_FLAGS=${EXTRA_CMAKE_FLAGS} # We do not want word splitting for EXTRA_CMAKE_FLAGS in case multiple are defined @@ -94,8 +94,8 @@ RUN [ -n "${WAMR_BUILD_TARGET:-}" ] && EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DW ARG CFLAGS="-v" ENV CFLAGS=${CFLAGS} -RUN make -j "$(getconf _NPROCESSORS_ONLN)" -RUN install bin/fluent-bit /fluent-bit/bin/ +RUN make -j "$(getconf _NPROCESSORS_ONLN)" && \ + install bin/fluent-bit /fluent-bit/bin/ # Configuration files COPY conf/fluent-bit.conf \ @@ -177,6 +177,7 @@ RUN find /dpkg/ -type d -empty -delete && \ # We want latest at time of build # hadolint ignore=DL3006 FROM gcr.io/distroless/cc-debian12 AS production +EXPOSE 2020 ARG RELEASE_VERSION ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} LABEL description="Fluent Bit multi-architecture container image" \ @@ -192,17 +193,15 @@ LABEL description="Fluent Bit multi-architecture container image" \ org.opencontainers.image.documentation="https://docs.fluentbit.io/" \ org.opencontainers.image.authors="Eduardo Silva " -# Copy the libraries from the extractor stage into root -COPY --from=deb-extractor /dpkg / - # Copy certificates COPY --from=builder /etc/ssl/certs /etc/ssl/certs +# Copy the libraries from the extractor stage into root +COPY --from=deb-extractor /dpkg / + # Finally the binaries as most likely to change COPY --from=builder /fluent-bit /fluent-bit -EXPOSE 2020 - # Entry point ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ] CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]