From 2446ce6dc7249fcd328e97ccdf1808726410fc3b Mon Sep 17 00:00:00 2001 From: Thibault VINCENT Date: Sat, 17 Sep 2022 14:12:20 +0200 Subject: [PATCH] build: rework dockerfile for development use only --- Dockerfile | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71b7b58..4abfe46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ ## Build Stage +# https://github.com/hadolint/hadolint/issues/861 +# hadolint ignore=DL3029 FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18.6-alpine as build -ARG TARGETOS -ARG TARGETARCH - WORKDIR $GOPATH/src/github.com/enix/x509-certificate-exporter COPY go.mod go.mod @@ -15,10 +14,15 @@ 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} -ARG VERSION="0.0.0" +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.CommitHash=${VCS_REF}\" \ @@ -28,25 +32,12 @@ ARG VERSION="0.0.0" ## Production Stage -LABEL maintainer="Enix " \ - org.opencontainers.image.title="X.509 Certificate Exporter" \ - org.opencontainers.image.description="A Prometheus exporter for certificates focusing on expiration monitoring." \ - org.opencontainers.image.url="https://github.com/enix/x509-certificate-exporter" \ - org.opencontainers.image.sources="https://github.com/enix/x509-certificate-exporter/blob/master/Dockerfile" \ - org.opencontainers.image.documentation="https://github.com/enix/x509-certificate-exporter/blob/master/README.md" \ - org.opencontainers.image.authors="Enix " \ - org.opencontainers.image.licenses="MIT" - -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.14.7 +# https://github.com/hadolint/hadolint/issues/861 +# hadolint ignore=DL3029 +FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.16.2 COPY --from=build /go/src/github.com/enix/x509-certificate-exporter/x509-certificate-exporter /x509-certificate-exporter EXPOSE 9793/tcp ENTRYPOINT [ "/x509-certificate-exporter" ] - -#ARG VCS_REF -#ARG BUILD_DATE -LABEL org.opencontainers.image.version="$VERSION" -# org.opencontainers.image.revision="$VCS_REF" \ -# org.opencontainers.image.created="$BUILD_DATE"