-
Notifications
You must be signed in to change notification settings - Fork 2
/
frr-exporter.Dockerfile
41 lines (31 loc) · 1.01 KB
/
frr-exporter.Dockerfile
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
ARG FRR_VERSION="10.1.0"
ARG REGISTRY="quay.io"
# Build the manager binary
FROM docker.io/library/golang:1.21-alpine as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Build router
RUN apk add llvm clang linux-headers libbpf-dev musl-dev
# Copy the go source
COPY cmd/frr-exporter/main.go main.go
COPY pkg/ pkg/
# Build router
COPY bpf/ bpf/
RUN cd pkg/bpf/ && go generate
ARG ldflags
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "${ldflags}" -a -o frr-exporter main.go
FROM ${REGISTRY}/frrouting/frr:${FRR_VERSION}
RUN apk add --no-cache frr
WORKDIR /
COPY --from=builder /workspace/frr-exporter .
## Needs to run as root
## vtysh is required to have extended rights
## to be able to connect to vty sockets on the host
# USER 65532:65532
ENTRYPOINT ["/frr-exporter"]