-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
43 lines (35 loc) · 1.44 KB
/
Dockerfile.template
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
40
41
42
# Use the current release in opentelemetry-collector-releases repo.
FROM golang:1.23 AS builder
# Build the otelcol builder -- the 'ocb' binary.
WORKDIR /app
RUN curl -LO https://github.com/open-telemetry/opentelemetry-collector-releases/archive/refs/tags/v0.112.0.tar.gz
RUN tar -zxvf v0.112.0.tar.gz
WORKDIR /app/opentelemetry-collector-releases-0.112.0
RUN make ocb
WORKDIR /app
RUN mv /root/bin/ocb /app/ocb
# Build the 'otelcol' collector binary with our custom manifest of receivers, exporters, etc.
COPY builder/manifest.yaml manifest.yaml
RUN ./ocb --config manifest.yaml
# journald exporter requires journalctl binary
FROM golang:1.23 AS journal
RUN apt-get update && apt-get install -y --no-install-recommends systemd
COPY startup/setup-journal.sh /
RUN /setup-journal.sh
# Run the collector
FROM busybox:stable
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/_build/otelcol .
# Workaround to copy individual directories. If attempt copy to root (/), get error
# "cannot copy to non-directory:" on an amd64 local build via 'docker buildx build'.
COPY --from=journal /sysroot/bin /bin
COPY --from=journal /sysroot/lib /lib
COPY --from=journal /sysroot/usr /usr
COPY startup/*.yaml ./
COPY startup/*.sh ./
RUN chmod a+x *.sh
# Dynamically assemble OTel collector configuration based on environment
# variables, and run it.
ENTRYPOINT ["./run_from_env.sh"]
EXPOSE 4317 55678 55679