-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile-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.1-alpine3.20
FROM golang@sha256:ac67716dd016429be8d4c2c53a248d7bcdf06d34127d3dc451bda6aa5a87bc06 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.20.3
FROM alpine@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
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"]