|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | +# check=skip=InvalidBaseImagePlatform |
| 3 | + |
| 4 | +# To use this container you may need to do the following: |
| 5 | +# https://askubuntu.com/a/1369504 |
| 6 | +# sudo add-apt-repository ppa:jacob/virtualisation #(for Ubuntu 20.04) |
| 7 | +# sudo apt-get update && sudo apt-get install qemu qemu-user qemu-user-static |
| 8 | +# https://stackoverflow.com/a/60667468 |
| 9 | +# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 10 | +# docker buildx rm builder |
| 11 | +# docker buildx create --name builder --use |
| 12 | +# docker buildx inspect --bootstrap |
| 13 | +# docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/ |
| 14 | + |
| 15 | +# Set this to the current release version: it gets done so as part of the release. |
| 16 | +ARG RELEASE_VERSION=4.2.1 |
| 17 | + |
| 18 | +# For multi-arch builds - assumption is running on an AMD64 host |
| 19 | +FROM multiarch/qemu-user-static:x86_64-arm AS qemu-arm32 |
| 20 | +FROM multiarch/qemu-user-static:x86_64-aarch64 AS qemu-arm64 |
| 21 | + |
| 22 | +FROM debian:bookworm-slim AS builder-base |
| 23 | + |
| 24 | +COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ |
| 25 | +COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ |
| 26 | + |
| 27 | +ARG FLB_NIGHTLY_BUILD |
| 28 | +ENV FLB_NIGHTLY_BUILD=$FLB_NIGHTLY_BUILD |
| 29 | + |
| 30 | +ARG FLB_CHUNK_TRACE=On |
| 31 | +ENV FLB_CHUNK_TRACE=${FLB_CHUNK_TRACE} |
| 32 | + |
| 33 | +RUN mkdir -p /fluent-bit/bin /fluent-bit/etc /fluent-bit/log |
| 34 | + |
| 35 | +ENV DEBIAN_FRONTEND=noninteractive |
| 36 | + |
| 37 | +# hadolint ignore=DL3008 |
| 38 | +RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ |
| 39 | + apt-get update && \ |
| 40 | + apt-get install -y --no-install-recommends \ |
| 41 | + build-essential \ |
| 42 | + curl \ |
| 43 | + ca-certificates \ |
| 44 | + git \ |
| 45 | + make \ |
| 46 | + tar \ |
| 47 | + libssl-dev \ |
| 48 | + libcurl4-openssl-dev \ |
| 49 | + libsasl2-dev \ |
| 50 | + pkg-config \ |
| 51 | + libsystemd-dev/bookworm-backports \ |
| 52 | + zlib1g-dev \ |
| 53 | + libpq-dev \ |
| 54 | + postgresql-server-dev-all \ |
| 55 | + flex \ |
| 56 | + bison \ |
| 57 | + libyaml-dev \ |
| 58 | + && apt-get satisfy -y cmake "cmake (<< 4.0)" \ |
| 59 | + && apt-get clean \ |
| 60 | + && rm -rf /var/lib/apt/lists/* |
| 61 | + |
| 62 | +# Must be run from root of repo |
| 63 | +WORKDIR /src/fluent-bit/ |
| 64 | +COPY . ./ |
| 65 | + |
| 66 | +# We split the builder setup out so people can target it or use as a base image without doing a full build. |
| 67 | +FROM builder-base AS builder |
| 68 | +WORKDIR /src/fluent-bit/build/ |
| 69 | + |
| 70 | +# Required to be set to ARMV7 for that target |
| 71 | +ARG WAMR_BUILD_TARGET |
| 72 | +ARG EXTRA_CMAKE_FLAGS |
| 73 | +ENV EXTRA_CMAKE_FLAGS=${EXTRA_CMAKE_FLAGS} |
| 74 | + |
| 75 | +# Enable jemalloc large page support via CMake option introduced in 5ca1c93 |
| 76 | +ARG FLB_JEMALLOC_OPTIONS="--with-lg-page=16 --with-lg-quantum=3" |
| 77 | +ENV FLB_JEMALLOC_OPTIONS=${FLB_JEMALLOC_OPTIONS} |
| 78 | + |
| 79 | +# We do not want word splitting for EXTRA_CMAKE_FLAGS in case multiple are defined |
| 80 | +# hadolint ignore=SC2086 |
| 81 | +RUN [ -n "${WAMR_BUILD_TARGET:-}" ] && EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DWAMR_BUILD_TARGET=$WAMR_BUILD_TARGET"; \ |
| 82 | + cmake -DFLB_SIMD=On \ |
| 83 | + -DFLB_RELEASE=On \ |
| 84 | + -DFLB_JEMALLOC=On \ |
| 85 | + -DFLB_TLS=On \ |
| 86 | + -DFLB_SHARED_LIB=Off \ |
| 87 | + -DFLB_EXAMPLES=Off \ |
| 88 | + -DFLB_HTTP_SERVER=On \ |
| 89 | + -DFLB_IN_EXEC=Off \ |
| 90 | + -DFLB_IN_SYSTEMD=On \ |
| 91 | + -DFLB_OUT_KAFKA=On \ |
| 92 | + -DFLB_OUT_PGSQL=On \ |
| 93 | + -DFLB_NIGHTLY_BUILD="$FLB_NIGHTLY_BUILD" \ |
| 94 | + -DFLB_LOG_NO_CONTROL_CHARS=On \ |
| 95 | + -DFLB_CHUNK_TRACE="$FLB_CHUNK_TRACE" \ |
| 96 | + -DFLB_JEMALLOC_OPTIONS="$FLB_JEMALLOC_OPTIONS" \ |
| 97 | + $EXTRA_CMAKE_FLAGS \ |
| 98 | + .. |
| 99 | + |
| 100 | +ARG CFLAGS="-v" |
| 101 | +ENV CFLAGS=${CFLAGS} |
| 102 | + |
| 103 | +RUN make -j "$(getconf _NPROCESSORS_ONLN)" |
| 104 | +RUN install bin/fluent-bit /fluent-bit/bin/ |
| 105 | + |
| 106 | +# Configuration files |
| 107 | +COPY conf/fluent-bit.conf \ |
| 108 | + conf/parsers.conf \ |
| 109 | + conf/parsers_ambassador.conf \ |
| 110 | + conf/parsers_java.conf \ |
| 111 | + conf/parsers_extra.conf \ |
| 112 | + conf/parsers_openstack.conf \ |
| 113 | + conf/parsers_cinder.conf \ |
| 114 | + conf/plugins.conf \ |
| 115 | + /fluent-bit/etc/ |
| 116 | + |
| 117 | +# Generate schema and include as part of the container image |
| 118 | +RUN /fluent-bit/bin/fluent-bit -J > /fluent-bit/etc/schema.json |
| 119 | + |
| 120 | +# Simple example of how to properly extract packages for reuse in distroless |
| 121 | +# Taken from: https://github.com/GoogleContainerTools/distroless/issues/863 |
| 122 | +FROM debian:bookworm-slim AS deb-extractor |
| 123 | +COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ |
| 124 | +COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ |
| 125 | + |
| 126 | +# We download all debs locally then extract them into a directory we can use as the root for distroless. |
| 127 | +# We also include some extra handling for the status files that some tooling uses for scanning, etc. |
| 128 | +WORKDIR /tmp |
| 129 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 130 | +RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ |
| 131 | + apt-get update && \ |
| 132 | + apt-get download \ |
| 133 | + libssl3 \ |
| 134 | + libcurl4 \ |
| 135 | + libnghttp2-14 \ |
| 136 | + librtmp1 \ |
| 137 | + libssh2-1 \ |
| 138 | + libpsl5 \ |
| 139 | + libbrotli1 \ |
| 140 | + libsasl2-2 \ |
| 141 | + pkg-config \ |
| 142 | + libpq5 \ |
| 143 | + libsystemd0/bookworm-backports \ |
| 144 | + zlib1g \ |
| 145 | + ca-certificates \ |
| 146 | + libatomic1 \ |
| 147 | + libgcrypt20 \ |
| 148 | + libzstd1 \ |
| 149 | + liblz4-1 \ |
| 150 | + libgssapi-krb5-2 \ |
| 151 | + libldap-2.5 \ |
| 152 | + libgpg-error0 \ |
| 153 | + libkrb5-3 \ |
| 154 | + libk5crypto3 \ |
| 155 | + libcom-err2 \ |
| 156 | + libkrb5support0 \ |
| 157 | + libgnutls30 \ |
| 158 | + libkeyutils1 \ |
| 159 | + libp11-kit0 \ |
| 160 | + libidn2-0 \ |
| 161 | + libunistring2 \ |
| 162 | + libtasn1-6 \ |
| 163 | + libnettle8 \ |
| 164 | + libhogweed6 \ |
| 165 | + libgmp10 \ |
| 166 | + libffi8 \ |
| 167 | + liblzma5 \ |
| 168 | + libyaml-0-2 \ |
| 169 | + libcap2 \ |
| 170 | + && \ |
| 171 | + mkdir -p /dpkg/var/lib/dpkg/status.d/ && \ |
| 172 | + for deb in *.deb; do \ |
| 173 | + package_name=$(dpkg-deb -I "${deb}" | awk '/^ Package: .*$/ {print $2}'); \ |
| 174 | + echo "Processing: ${package_name}"; \ |
| 175 | + dpkg --ctrl-tarfile "$deb" | tar -Oxf - ./control > "/dpkg/var/lib/dpkg/status.d/${package_name}"; \ |
| 176 | + dpkg --extract "$deb" /dpkg || exit 10; \ |
| 177 | + done |
| 178 | + |
| 179 | +# Remove unnecessary files extracted from deb packages like man pages and docs etc. |
| 180 | +RUN find /dpkg/ -type d -empty -delete && \ |
| 181 | + rm -r /dpkg/usr/share/doc/ |
| 182 | + |
| 183 | +# We want latest at time of build |
| 184 | +# hadolint ignore=DL3006 |
| 185 | +FROM gcr.io/distroless/cc-debian12 AS production |
| 186 | +ARG RELEASE_VERSION |
| 187 | +ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} |
| 188 | +LABEL description="Fluent Bit multi-architecture container image" \ |
| 189 | + vendor="Fluent Organization" \ |
| 190 | + version="${RELEASE_VERSION}" \ |
| 191 | + author="Eduardo Silva < [email protected]>" \ |
| 192 | + org.opencontainers.image.description="Fluent Bit container image" \ |
| 193 | + org.opencontainers.image.title="Fluent Bit" \ |
| 194 | + org.opencontainers.image.licenses="Apache-2.0" \ |
| 195 | + org.opencontainers.image.vendor="Fluent Organization" \ |
| 196 | + org.opencontainers.image.version="${RELEASE_VERSION}" \ |
| 197 | + org.opencontainers.image.source="https://github.com/fluent/fluent-bit" \ |
| 198 | + org.opencontainers.image.documentation="https://docs.fluentbit.io/" \ |
| 199 | + org.opencontainers.image.authors="Eduardo Silva < [email protected]>" |
| 200 | + |
| 201 | +# Copy the libraries from the extractor stage into root |
| 202 | +COPY --from=deb-extractor /dpkg / |
| 203 | + |
| 204 | +# Copy certificates |
| 205 | +COPY --from=builder /etc/ssl/certs /etc/ssl/certs |
| 206 | + |
| 207 | +# Finally the binaries as most likely to change |
| 208 | +COPY --from=builder /fluent-bit /fluent-bit |
| 209 | + |
| 210 | +EXPOSE 2020 |
| 211 | + |
| 212 | +# Entry point |
| 213 | +ENTRYPOINT [ "/fluent-bit/bin/fluent-bit" ] |
| 214 | +CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"] |
| 215 | + |
| 216 | +FROM debian:bookworm-slim AS debug |
| 217 | +ARG RELEASE_VERSION |
| 218 | +ENV FLUENT_BIT_VERSION=${RELEASE_VERSION} |
| 219 | +LABEL description="Fluent Bit multi-architecture debug container image" \ |
| 220 | + vendor="Fluent Organization" \ |
| 221 | + version="${RELEASE_VERSION}-debug" \ |
| 222 | + author="Eduardo Silva < [email protected]>" \ |
| 223 | + org.opencontainers.image.description="Fluent Bit debug container image" \ |
| 224 | + org.opencontainers.image.title="Fluent Bit Debug" \ |
| 225 | + org.opencontainers.image.licenses="Apache-2.0" \ |
| 226 | + org.opencontainers.image.vendor="Fluent Organization" \ |
| 227 | + org.opencontainers.image.version="${RELEASE_VERSION}-debug" \ |
| 228 | + org.opencontainers.image.source="https://github.com/fluent/fluent-bit" \ |
| 229 | + org.opencontainers.image.documentation="https://docs.fluentbit.io/" \ |
| 230 | + org.opencontainers.image.authors="Eduardo Silva < [email protected]>" |
| 231 | + |
| 232 | +COPY --from=qemu-arm32 /usr/bin/qemu-arm-static /usr/bin/ |
| 233 | +COPY --from=qemu-arm64 /usr/bin/qemu-aarch64-static /usr/bin/ |
| 234 | +ENV DEBIAN_FRONTEND=noninteractive |
| 235 | + |
| 236 | +# hadolint ignore=DL3008 |
| 237 | +RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \ |
| 238 | + apt-get update && \ |
| 239 | + apt-get install -y --no-install-recommends \ |
| 240 | + libssl3 \ |
| 241 | + libcurl4 \ |
| 242 | + libnghttp2-14 \ |
| 243 | + librtmp1 \ |
| 244 | + libssh2-1 \ |
| 245 | + libpsl5 \ |
| 246 | + libbrotli1 \ |
| 247 | + libsasl2-2 \ |
| 248 | + pkg-config \ |
| 249 | + libpq5 \ |
| 250 | + libsystemd0/bookworm-backports \ |
| 251 | + zlib1g \ |
| 252 | + ca-certificates \ |
| 253 | + libatomic1 \ |
| 254 | + libgcrypt20 \ |
| 255 | + libyaml-0-2 \ |
| 256 | + bash gdb valgrind build-essential \ |
| 257 | + git bash-completion vim tmux jq \ |
| 258 | + dnsutils iputils-ping iputils-arping iputils-tracepath iputils-clockdiff \ |
| 259 | + tcpdump curl nmap tcpflow iftop \ |
| 260 | + net-tools mtr netcat-openbsd bridge-utils iperf ngrep \ |
| 261 | + openssl \ |
| 262 | + htop atop strace iotop sysstat ncdu logrotate hdparm pciutils psmisc tree pv \ |
| 263 | + make tar flex bison \ |
| 264 | + libssl-dev libsasl2-dev libsystemd-dev/bookworm-backports zlib1g-dev libpq-dev libyaml-dev postgresql-server-dev-all \ |
| 265 | + && apt-get satisfy -y cmake "cmake (<< 4.0)" \ |
| 266 | + && apt-get clean \ |
| 267 | + && rm -rf /var/lib/apt/lists/* |
| 268 | + |
| 269 | +RUN rm -f /usr/bin/qemu-*-static |
| 270 | +COPY --from=builder /fluent-bit /fluent-bit |
| 271 | + |
| 272 | +EXPOSE 2020 |
| 273 | + |
| 274 | +# No entry point so we can just shell in |
| 275 | +CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"] |
| 276 | + |
| 277 | + |
0 commit comments