Skip to content

Commit

Permalink
Fix 32-bit Promtail ARM docker builds from Drone (#1740)
Browse files Browse the repository at this point in the history
* link ld-linux-armhf.so.3 when building 32-bit arm promtail image if needed

* Update .drone/drone.jsonnet

Co-Authored-By: sh0rez <me@shorez.de>

* review feedback

Co-authored-by: sh0rez <me@shorez.de>
  • Loading branch information
rfratto and sh0rez authored Feb 25, 2020
1 parent 0ffa65a commit ab4d885
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
25 changes: 24 additions & 1 deletion .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,30 @@ 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 {
steps: [
step + (
if std.objectHas(step, 'settings') && step.settings.dockerfile == 'cmd/promtail/Dockerfile'
then {
settings+: {
dockerfile: 'cmd/promtail/Dockerfile.arm32',
},
}
else {}
)
for step in super.steps
],
}
else {}
)
for arch in archs
] + [
fluentbit(),
Expand Down
4 changes: 2 additions & 2 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions cmd/promtail/Dockerfile.arm32
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit ab4d885

Please sign in to comment.