-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile_local
39 lines (33 loc) · 1.42 KB
/
Dockerfile_local
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM golang:1.22.8-alpine AS builder
ADD . /src
WORKDIR /src/otelcolbuilder/
ENV CGO_ENABLED=0
RUN apk --update add make gcc g++ curl git
RUN make install-builder BUILDER_BIN_PATH=/bin
RUN make build BUILDER_BIN_PATH=/bin
FROM alpine:3.20.2 AS certs
RUN apk --update add ca-certificates
FROM alpine:3.20.2 AS directories
RUN mkdir /etc/otel/
FROM debian:12.6 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 "\/.*? ")
# extract package to /output so it can be taken as base for scratch image
# we do not copy archive into scratch image, as it doesn't have tar executable
# however, we can copy full directory as root (/) to be base file structure for scratch image
RUN mkdir /output && tar xf /journalctl.tar.gz --directory /output
FROM scratch
ARG BUILD_TAG=latest
ENV TAG=$BUILD_TAG
ARG USER_UID=10001
USER ${USER_UID}
ENV HOME=/etc/otel/
# copy journalctl and it's dependencies AS base structure
COPY --from=systemd /output/ /
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /src/otelcolbuilder/cmd/otelcol-sumo /otelcol-sumo
COPY --from=directories --chown=${USER_UID}:${USER_UID} /etc/otel/ /etc/otel/
ENTRYPOINT ["/otelcol-sumo"]
CMD ["--config", "/etc/otel/config.yaml"]