From 7bce7724915d1bdc8dd808d8c106bc478d0fbc40 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Mon, 17 Sep 2018 12:13:45 +0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e8d7c5c..7da5b9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,32 @@ -FROM golang:1.10-alpine as go +FROM golang:1.10-alpine as build -WORKDIR /go/src/hello-world +# args +ARG version="1.0.0" +ARG repo="github.com/productionwentdown/hello-world" + +# source +WORKDIR $GOPATH/src/${repo} COPY . . + +# build ENV CGO_ENABLED=0 ENV GOOS=linux ENV GOARCH=amd64 -RUN go build -ldflags '-extldflags "-static"' -o hello-world +RUN go build -ldflags "-s -w" -o /hello-world FROM scratch +ARG version + +# labels +LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/hello-world" +LABEL org.label-schema.version=${version} +LABEL org.label-schema.schema-version="1.0" + +# copy binary +COPY --from=build /hello-world /hello-world + EXPOSE 8080 -COPY --from=go /go/src/hello-world/hello-world hello-world ENTRYPOINT ["/hello-world"]