-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile-builder
35 lines (21 loc) · 995 Bytes
/
Dockerfile-builder
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
# 1.23.4-alpine3.21
FROM golang@sha256:6c5c9590f169f77c8046e45c611d3b28fe477789acd8d3762d23d4744de69812 as builder
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go
RUN apk add --no-cache curl wget gcc make bash git musl-dev libc6-compat gettext
WORKDIR /go/github.com/thought-machine/prometheus-cardinality-exporter
COPY . .
RUN go build ./...
RUN go test ./... -race
# So the binary is where we expect it
# env var and flags ensure a static binary
RUN CGO_ENABLED=0 go build -ldflags="-extldflags=-static" .
# alpine:3.21.0
FROM alpine@sha256:21dc6063fd678b478f57c0e13f47560d0ea4eeba26dfc947b2a4f81f686b9f45
EXPOSE 9090
COPY --from=builder /go/github.com/thought-machine/prometheus-cardinality-exporter/prometheus-cardinality-exporter /home/app/prometheus-cardinality-exporter
# Max user
RUN addgroup -g 255999 -S app && \
adduser -u 255999 -S app -G app
RUN chmod +x /home/app/prometheus-cardinality-exporter
USER app
ENTRYPOINT ["/home/app/prometheus-cardinality-exporter"]