-
Notifications
You must be signed in to change notification settings - Fork 68
/
Dockerfile
43 lines (29 loc) · 1.14 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
37
38
39
40
41
42
43
## Build Stage
# https://github.com/hadolint/hadolint/issues/861
# hadolint ignore=DL3029
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23.2-alpine as build
WORKDIR $GOPATH/src/github.com/enix/x509-certificate-exporter
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY internal internal
COPY cmd cmd
ARG VERSION="devel"
ARG VCS_REF="unknown"
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
RUN go build -v \
-tags netgo,osusergo \
-ldflags "-X \"github.com/enix/x509-certificate-exporter/v3/internal.Version=${VERSION}\" \
-X \"github.com/enix/x509-certificate-exporter/v3/internal.Revision=${VCS_REF}\" \
-X \"github.com/enix/x509-certificate-exporter/v3/internal.BuildDateTime=$(date -u -Iseconds)\"" \
./cmd/x509-certificate-exporter
## Production Stage
# https://github.com/hadolint/hadolint/issues/861
# hadolint ignore=DL3029
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.20.3
COPY --from=build /go/src/github.com/enix/x509-certificate-exporter/x509-certificate-exporter /x509-certificate-exporter
EXPOSE 9793/tcp
ENTRYPOINT [ "/x509-certificate-exporter" ]