Skip to content

Commit 8a9b564

Browse files
author
Pat
authored
dockerfiles: distroless for multiarch (fluent#4686)
* dockerfiles: distroless for multiarch Signed-off-by: Patrick Stephens <pat@calyptia.com> * dockerfiles: linting fixes Signed-off-by: Patrick Stephens <pat@calyptia.com> * dockerfiles: remove unnecessary RUN Signed-off-by: Patrick Stephens <pat@calyptia.com> * dockerfiles: linting fixes Signed-off-by: Patrick Stephens <pat@calyptia.com> * dockerfiles: add missing dependencies Signed-off-by: Patrick Stephens <pat@calyptia.com> * workflows: smoke test PR multiarch Signed-off-by: Patrick Stephens <pat@calyptia.com>
1 parent 00141d6 commit 8a9b564

File tree

2 files changed

+73
-24
lines changed

2 files changed

+73
-24
lines changed

.github/workflows/pr-image-tests.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ jobs:
5151
secrets:
5252
token: ${{ secrets.GITHUB_TOKEN }}
5353

54+
pr-image-tests-smoke-test-multiarch-images:
55+
name: PR - multiarch smoke test images
56+
needs: [pr-get-latest-tag, pr-image-tests-build-images]
57+
uses: fluent/fluent-bit/.github/workflows/call-test-images.yaml@master
58+
with:
59+
registry: ghcr.io
60+
username: ${{ github.actor }}
61+
image: ${{ github.repository }}/pr-${{ github.event.number }}/multiarch
62+
image-tag: ${{ needs.pr-get-latest-tag.outputs.latest_tag }}
63+
environment: pr
64+
secrets:
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
5467
pr-image-tests-classic-docker-build:
5568
name: PR - Classic docker build test
5669
needs: pr-get-latest-tag

dockerfiles/Dockerfile.multiarch

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,51 @@ COPY conf/fluent-bit.conf \
8181
conf/plugins.conf \
8282
/fluent-bit/etc/
8383

84-
# FROM gcr.io/distroless/cc-debian11 as production
85-
FROM debian:bullseye-slim as production
84+
# Simple example of how to properly extract packages for reuse in distroless
85+
# Taken from: https://github.com/GoogleContainerTools/distroless/issues/863
86+
FROM debian:bullseye-slim as deb-extractor
87+
COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/
88+
COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/
89+
90+
# We download all debs locally then extract them into a directory we can use as the root for distroless
91+
WORKDIR /tmp
92+
RUN apt-get update && \
93+
apt-get download \
94+
libssl1.1 \
95+
libsasl2-2 \
96+
pkg-config \
97+
libpq5 \
98+
libsystemd0 \
99+
zlib1g \
100+
ca-certificates \
101+
libatomic1 \
102+
libgcrypt20 \
103+
libzstd1 \
104+
liblz4-1 \
105+
libgssapi-krb5-2 \
106+
libldap-2.4-2 \
107+
libgpg-error0 \
108+
libkrb5-3 \
109+
libk5crypto3 \
110+
libcom-err2 \
111+
libkrb5support0 \
112+
libgnutls30 \
113+
libkeyutils1 \
114+
libp11-kit0 \
115+
libidn2-0 \
116+
libunistring2 \
117+
libtasn1-6 \
118+
libnettle8 \
119+
libhogweed6 \
120+
libgmp10 \
121+
libffi7 \
122+
liblzma5 && \
123+
mkdir -p /dpkg && \
124+
for deb in *.deb; do dpkg --extract "$deb" /dpkg || exit 10; done
125+
126+
# We want latest at time of build
127+
# hadolint ignore=DL3006
128+
FROM gcr.io/distroless/cc-debian11 as production
86129
LABEL description="Fluent Bit multi-architecture container image" \
87130
vendor="Fluent Organization" \
88131
version="1.9.0" \
@@ -96,34 +139,18 @@ LABEL description="Fluent Bit multi-architecture container image" \
96139
org.opencontainers.image.documentation="https://docs.fluentbit.io/manual/" \
97140
org.opencontainers.image.authors="Eduardo Silva <eduardo@calyptia.com>"
98141

99-
COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/
100-
COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/
101-
102-
# hadolint ignore=DL3008
103-
RUN apt-get update && \
104-
apt-get install -y --no-install-recommends \
105-
libssl1.1 \
106-
libsasl2-2 \
107-
pkg-config \
108-
libpq5 \
109-
libsystemd0 \
110-
zlib1g \
111-
ca-certificates \
112-
libatomic1 \
113-
libgcrypt20 \
114-
&& apt-get clean \
115-
&& rm -rf /var/lib/apt/lists/*
142+
# Copy the libraries from the extractor stage into root
143+
COPY --from=deb-extractor /dpkg /
116144

117145
COPY --from=builder /fluent-bit /fluent-bit
118-
RUN rm -f /usr/bin/qemu-*-static
119146

120147
EXPOSE 2020
121148

122149
# Entry point
123150
ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ]
124151
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]
125152

126-
FROM production as debug
153+
FROM debian:bullseye-slim as debug
127154
LABEL description="Fluent Bit multi-architecture container image" \
128155
vendor="Fluent Organization" \
129156
version="1.9.0" \
@@ -136,14 +163,23 @@ ENV DEBIAN_FRONTEND noninteractive
136163
# hadolint ignore=DL3008
137164
RUN apt-get update && \
138165
apt-get install -y --no-install-recommends \
139-
bash gdb valgrind build-essential \
166+
libssl1.1 \
167+
libsasl2-2 \
168+
pkg-config \
169+
libpq5 \
170+
libsystemd0 \
171+
zlib1g \
172+
ca-certificates \
173+
libatomic1 \
174+
libgcrypt20 \
175+
bash gdb valgrind build-essential \
140176
&& apt-get clean \
141177
&& rm -rf /var/lib/apt/lists/*
142178

143179
RUN rm -f /usr/bin/qemu-*-static
180+
COPY --from=builder /fluent-bit /fluent-bit
144181

145182
EXPOSE 2020
146183

147-
# Entry point
148-
ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ]
184+
# No entry point so we can just shell in
149185
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]

0 commit comments

Comments
 (0)