forked from thought-machine/prometheus-cardinality-exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
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.20.5-alpine3.18
FROM golang@sha256:6b6fd1071edb52b61f79aec51281c55050f58dd58e2080b4e24556607c98086f 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.18.0
FROM alpine@sha256:c0669ef34cdc14332c0f1ab0c2c01acb91d96014b172f1a76f3a39e63d1f0bda
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"]