-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
29 lines (22 loc) · 812 Bytes
/
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
#
# build container
#
FROM golang:1.21-alpine as builder
WORKDIR /go/src/github.com/oliver006/rethinkdb_exporter/
ADD . /go/src/github.com/oliver006/rethinkdb_exporter/
ARG GOARCH="amd64"
ARG SHA1="[no-sha]"
ARG TAG="[no-tag]"
RUN apk --no-cache add ca-certificates
RUN BUILD_DATE=$(date +%F-%T) && CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH go build -o /bin/rethinkdb_exporter \
-ldflags "-s -w -extldflags \"-static\" -X main.BuildVersion=$TAG -X main.BuildCommitSha=$SHA1 -X main.BuildDate=$BUILD_DATE" .
#
# scratch release container
#
FROM scratch as scratch
COPY --from=builder /bin/rethinkdb_exporter /bin/rethinkdb_exporter
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Run as non-root user for secure environments
USER 59000:59000
EXPOSE 9123
ENTRYPOINT [ "/bin/rethinkdb_exporter" ]