From 0f6c1695bc5b030553ff2e06daa1567cf3d6c958 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 27 Jan 2021 21:13:02 +0100 Subject: [PATCH] Improve Dockerfile Signed-off-by: Knut Ahlers --- Dockerfile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 28e68c3..4074116 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,27 @@ -FROM golang:alpine +FROM golang:alpine as builder -LABEL maintainer "Knut Ahlers " - -ADD . /go/src/github.com/Luzifer/share +COPY . /go/src/github.com/Luzifer/share WORKDIR /go/src/github.com/Luzifer/share RUN set -ex \ - && apk add --update git ca-certificates \ - && go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)" \ - && apk del --purge git + && apk add --update git \ + && go install \ + -ldflags "-X main.version=$(git describe --tags --always || echo dev)" \ + -mod=readonly + +FROM alpine:latest + +LABEL maintainer "Knut Ahlers " + +RUN set -ex \ + && apk --no-cache add \ + ca-certificates + +COPY --from=builder /go/bin/share /usr/local/bin/share EXPOSE 3000 -ENTRYPOINT ["/go/bin/share"] +ENTRYPOINT ["/usr/local/bin/share"] CMD ["--"] + +# vim: set ft=Dockerfile: