Skip to content

Commit 7319f03

Browse files
committed
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 <marco.franssen@gmail.com>
1 parent 2191be4 commit 7319f03

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

dockerfiles/Dockerfile

+14-15
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ FROM debian:bookworm-slim AS builder-base
2424
COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/
2525
COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/
2626

27-
ARG FLB_NIGHTLY_BUILD
28-
ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD
27+
ARG FLB_NIGHTLY_BUILD \
28+
FLB_CHUNK_TRACE=On
2929

30-
ARG FLB_CHUNK_TRACE=On
31-
ENV FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE}
30+
ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD \
31+
FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE} \
32+
DEBIAN_FRONTEND=noninteractive
3233

3334
RUN mkdir -p /fluent-bit/bin /fluent-bit/etc /fluent-bit/log
3435

35-
ENV DEBIAN_FRONTEND=noninteractive
36-
3736
# hadolint ignore=DL3008
3837
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \
3938
apt-get update && \
@@ -68,8 +67,9 @@ FROM builder-base AS builder
6867
WORKDIR /src/fluent-bit/build/
6968

7069
# Required to be set to ARMV7 for that target
71-
ARG WAMR_BUILD_TARGET
72-
ARG EXTRA_CMAKE_FLAGS
70+
ARG WAMR_BUILD_TARGET \
71+
EXTRA_CMAKE_FLAGS
72+
7373
ENV EXTRA_CMAKE_FLAGS=${EXTRA_CMAKE_FLAGS}
7474

7575
# 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
9494
ARG CFLAGS="-v"
9595
ENV CFLAGS=${CFLAGS}
9696

97-
RUN make -j "$(getconf _NPROCESSORS_ONLN)"
98-
RUN install bin/fluent-bit /fluent-bit/bin/
97+
RUN make -j "$(getconf _NPROCESSORS_ONLN)" && \
98+
install bin/fluent-bit /fluent-bit/bin/
9999

100100
# Configuration files
101101
COPY conf/fluent-bit.conf \
@@ -177,6 +177,7 @@ RUN find /dpkg/ -type d -empty -delete && \
177177
# We want latest at time of build
178178
# hadolint ignore=DL3006
179179
FROM gcr.io/distroless/cc-debian12 AS production
180+
EXPOSE 2020
180181
ARG RELEASE_VERSION
181182
ENV FLUENT_BIT_VERSION=${RELEASE_VERSION}
182183
LABEL description="Fluent Bit multi-architecture container image" \
@@ -192,17 +193,15 @@ LABEL description="Fluent Bit multi-architecture container image" \
192193
org.opencontainers.image.documentation="https://docs.fluentbit.io/" \
193194
org.opencontainers.image.authors="Eduardo Silva <eduardo.silva@chronosphere.io>"
194195

195-
# Copy the libraries from the extractor stage into root
196-
COPY --from=deb-extractor /dpkg /
197-
198196
# Copy certificates
199197
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
200198

199+
# Copy the libraries from the extractor stage into root
200+
COPY --from=deb-extractor /dpkg /
201+
201202
# Finally the binaries as most likely to change
202203
COPY --from=builder /fluent-bit /fluent-bit
203204

204-
EXPOSE 2020
205-
206205
# Entry point
207206
ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ]
208207
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]

0 commit comments

Comments
 (0)