Skip to content

Commit

Permalink
fix(build): fix dev Dockerfile
Browse files Browse the repository at this point in the history
The dev Dockerfile uses the official Go image as the base for the
final stage, and copies journalctl and dependencies from a debian image.
This is consistent with the production image, but that uses scratch,
while the golang image also uses Debian as base. As a result, if the
debian versions diverge, it's possible to get cryptic errors about
glibc versions, as has recently happened in our CI.

Instead, skip the intermediate step and install systemd in the
final image directly.
  • Loading branch information
Mikołaj Świątek committed Jun 23, 2023
1 parent 178d930 commit 19178f6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Dockerfile_dev
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,20 @@ RUN apk --update add ca-certificates
FROM alpine:3.18.2 as directories
RUN mkdir /etc/otel/

FROM debian:11.7 as systemd
RUN apt update && apt install -y systemd
# prepare package with journald and it's dependencies keeping original paths
# h stands for dereference of symbolic links
RUN tar czhf journalctl.tar.gz /bin/journalctl $(ldd /bin/journalctl | grep -oP "\/.*? ")

FROM golang:1.20.5
ARG BUILD_TAG=latest
ENV TAG $BUILD_TAG
ARG USER_UID=10001

# Install systemd
RUN apt-get update && apt-get install -y systemd && rm -rf /var/lib/apt/lists/*

USER ${USER_UID}
ENV HOME /etc/otel/

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=otelcol /otelcol-sumo /otelcol-sumo
COPY --from=directories --chown=${USER_UID}:${USER_UID} /etc/otel/ /etc/otel/

# copy and extract journald with dependencies
COPY --from=systemd --chown=${USER_UID}:${USER_UID} /journalctl.tar.gz /journalctl.tar.gz
USER root
RUN tar xf /journalctl.tar.gz --directory / && rm /journalctl.tar.gz
USER ${USER_UID}

ENTRYPOINT ["/otelcol-sumo"]
CMD ["--config", "/etc/otel/config.yaml"]

0 comments on commit 19178f6

Please sign in to comment.