1
0
Fork 0

Update Dockerfile

master
Ambrose Chua 2018-09-17 12:13:45 +08:00 committed by GitHub
parent 61a6138b89
commit 7bce772491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 4 deletions

View File

@ -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"]