Skip to content

Dockerfile: optimize layers #10103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved up, as this is not likely to change, meaning the layer doesn't have to be rebuild,pushed,pulled.

ARG RELEASE_VERSION
ENV FLUENT_BIT_VERSION=${RELEASE_VERSION}
LABEL description="Fluent Bit multi-architecture container image" \
Expand All @@ -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 <[email protected]>"

# 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"]
Expand Down