From 7cac14893615d73284bf203fb4e86cfbb79c9104 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Mon, 17 Sep 2018 12:05:51 +0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2eb89d3..71e531e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,36 @@ -ARG name="email-collector" -ARG repo="github.com/productionwentdown/${name}" +FROM golang:1.10-alpine as build +# args +ARG version="1.0.0" +ARG repo="github.com/productionwentdown/email-collector" -FROM golang:1.10-alpine as go - +# dependencies RUN apk add --no-cache ca-certificates -ARG name -ARG repo -WORKDIR /go/src/${repo} +# source +WORKDIR $GOPATH/src/${repo} COPY . . + +# build ENV CGO_ENABLED=0 ENV GOOS=linux ENV GOARCH=amd64 -RUN go build -ldflags '-extldflags "-static"' -o ${name} +RUN go build -ldflags "-s -w" -o /email-collector FROM scratch -ARG name -ARG repo +ARG version + +# labels +LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/email-collector" +LABEL org.label-schema.version=${version} +LABEL org.label-schema.schema-version="1.0" + +# copy binary and ca certs +COPY --from=build /email-collector /email-collector +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt EXPOSE 8080 -COPY --from=go /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=go /go/src/${repo}/${name} /${name} ENTRYPOINT ["/email-collector"]