forked from nginx/nginx-prometheus-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (26 loc) · 1.06 KB
/
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
FROM golang:1.17 as base
ARG VERSION
ARG GIT_COMMIT
ARG DATE
ARG TARGETARCH
WORKDIR /go/src/github.com/nginxinc/nginx-prometheus-exporter
FROM base as builder
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
COPY collector ./collector
COPY client ./client
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -trimpath -a -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${DATE}" -o nginx-prometheus-exporter .
FROM scratch as intermediate
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
USER 1001:1001
ENTRYPOINT [ "/usr/bin/nginx-prometheus-exporter" ]
FROM intermediate as container
COPY --from=builder /go/src/github.com/nginxinc/nginx-prometheus-exporter/nginx-prometheus-exporter /usr/bin/
FROM intermediate as goreleaser
ARG TARGETARCH
ARG TARGETVARIANT
ARG TARGETPLATFORM
LABEL org.nginx.exporter.image.build.target="${TARGETPLATFORM}"
LABEL org.nginx.exporter.image.build.version="goreleaser"
COPY dist/nginx-prometheus-exporter_linux_$TARGETARCH${TARGETVARIANT:+_7}*/nginx-prometheus-exporter /usr/bin/