-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 1.25 KB
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 1.25 KB
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
FROM --platform=$BUILDPLATFORM golang:1.26.1-bookworm@sha256:c7a82e9e2df2fea5d8cb62a16aa6f796d2b2ed81ccad4ddd2bc9f0d22936c3f2 AS base
RUN apt-get update && apt-get install -y curl clang gcc llvm make libbpf-dev
FROM --platform=$BUILDPLATFORM base AS builder
WORKDIR /usr/src/go.opentelemetry.io/auto/
# Copy auto/sdk so `go mod` finds the replaced module.
COPY sdk/ /usr/src/go.opentelemetry.io/auto/sdk/
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading
# them in subsequent builds if they change
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg \
go mod download && go mod verify
COPY . .
ARG TARGETARCH
ENV GOARCH=$TARGETARCH
ARG CGO_ENABLED=0
ENV CGO_ENABLED=$CGO_ENABLED
ARG BPF2GO_CFLAGS="-I/usr/src/go.opentelemetry.io/auto/internal/include/libbpf -I/usr/src/go.opentelemetry.io/auto/internal/include"
ENV BPF2GO_CFLAGS=$BPF2GO_CFLAGS
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
go generate ./... \
&& go build -o otel-go-instrumentation ./cli/...
FROM gcr.io/distroless/base-debian12@sha256:937c7eaaf6f3f2d38a1f8c4aeff326f0c56e4593ea152e9e8f74d976dde52f56
COPY --from=builder /usr/src/go.opentelemetry.io/auto/otel-go-instrumentation /
CMD ["/otel-go-instrumentation"]