From 2d5e37cbf7f326c8f6705ad1d724b446e17e74fd Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Mon, 24 Feb 2020 17:37:03 -0500 Subject: [PATCH 1/3] link ld-linux-armhf.so.3 when building 32-bit arm promtail image if needed --- .drone/drone.jsonnet | 24 +++++++++++++++++++++++- .drone/drone.yml | 4 ++-- cmd/promtail/Dockerfile.arm32 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 cmd/promtail/Dockerfile.arm32 diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index 23f0ef7b17ed..536cdbbd44a0 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -153,7 +153,29 @@ local manifest(apps) = pipeline('manifest') { ], }, ] + [ - multiarch_image(arch) + multiarch_image(arch) + ( + // When we're building Promtail for ARM, we want to use Dockerfile.arm32 to fix + // a problem with the published Drone image. See Dockerfile.arm32 for more + // information. + // + // This is really really hacky and a better more permanent solution will be to use + // buildkit. + if arch != 'arm' then {} + else { + steps: [ + step + ( + if step.name == 'build-promtail-image' || step.name == 'publish-promtail-image' + then { + settings+: { + dockerfile: 'cmd/promtail/Dockerfile.arm32', + }, + } + else {} + ) + for step in super.steps + ], + } + ) for arch in archs ] + [ fluentbit(), diff --git a/.drone/drone.yml b/.drone/drone.yml index 68331f2a9c4f..4fd459746d59 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -368,7 +368,7 @@ steps: settings: build_args: - TOUCH_PROTOS=1 - dockerfile: cmd/promtail/Dockerfile + dockerfile: cmd/promtail/Dockerfile.arm32 dry_run: true password: from_secret: docker_password @@ -424,7 +424,7 @@ steps: settings: build_args: - TOUCH_PROTOS=1 - dockerfile: cmd/promtail/Dockerfile + dockerfile: cmd/promtail/Dockerfile.arm32 password: from_secret: docker_password repo: grafana/promtail diff --git a/cmd/promtail/Dockerfile.arm32 b/cmd/promtail/Dockerfile.arm32 new file mode 100644 index 000000000000..64264b5291df --- /dev/null +++ b/cmd/promtail/Dockerfile.arm32 @@ -0,0 +1,30 @@ +FROM golang:1.13 as build +# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them. +# This is helpful when file system timestamps can't be trusted with make +ARG TOUCH_PROTOS +COPY . /src/loki +WORKDIR /src/loki +RUN apt-get update && apt-get install -qy libsystemd-dev +RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false promtail + +# Promtail requires debian as the base image to support systemd journal reading +FROM debian:stretch-slim +# tzdata required for the timestamp stage to work +RUN apt-get update && \ + apt-get install -qy \ + tzdata ca-certificates libsystemd-dev && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +COPY --from=build /src/loki/cmd/promtail/promtail /usr/bin/promtail +COPY cmd/promtail/promtail-local-config.yaml /etc/promtail/local-config.yaml +COPY cmd/promtail/promtail-docker-config.yaml /etc/promtail/docker-config.yaml + +# Drone CI builds arm32 images using armv8l rather than armv7l. Something in +# our build process above causes ldconfig to be rerun and removes the armhf +# library that debian:stretch-slim on ARM comes with. Symbolically linking to +# ld-linux.so.3 fixes the problem and allows Promtail to start. +# +# This process isn't necessary when building on armv7l so we only do it if the +# library was removed. +RUN sh -c '[ ! -f /lib/ld-linux-armhf.so.3 ] && echo RE-LINKING LD-LINUX-ARMHF.SO.3 && ln -s /lib/ld-linux.so.3 /lib/ld-linux-armhf.so.3' + +ENTRYPOINT ["/usr/bin/promtail"] From 9bad6b743ee34856fc16e29b76065ac1ffa57784 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 25 Feb 2020 09:58:33 -0500 Subject: [PATCH 2/3] Update .drone/drone.jsonnet Co-Authored-By: sh0rez --- .drone/drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index 536cdbbd44a0..2a1040a129e5 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -164,7 +164,7 @@ local manifest(apps) = pipeline('manifest') { else { steps: [ step + ( - if step.name == 'build-promtail-image' || step.name == 'publish-promtail-image' + if step.settings.dockerfile == "cmd/promtail/Dockerfile" then { settings+: { dockerfile: 'cmd/promtail/Dockerfile.arm32', From 48a6f5d74b385e7f53122bf85d730ed9a27036c1 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 25 Feb 2020 10:01:17 -0500 Subject: [PATCH 3/3] review feedback --- .drone/drone.jsonnet | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index 2a1040a129e5..6f48c1987395 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -160,11 +160,11 @@ local manifest(apps) = pipeline('manifest') { // // This is really really hacky and a better more permanent solution will be to use // buildkit. - if arch != 'arm' then {} - else { + if arch == 'arm' + then { steps: [ step + ( - if step.settings.dockerfile == "cmd/promtail/Dockerfile" + if std.objectHas(step, 'settings') && step.settings.dockerfile == 'cmd/promtail/Dockerfile' then { settings+: { dockerfile: 'cmd/promtail/Dockerfile.arm32', @@ -175,6 +175,7 @@ local manifest(apps) = pipeline('manifest') { for step in super.steps ], } + else {} ) for arch in archs ] + [