1
0
Fork 0
hello-world/Dockerfile

33 lines
574 B
Docker
Raw Normal View History

2018-09-17 12:13:45 +08:00
FROM golang:1.10-alpine as build
2017-12-02 00:16:37 +08:00
2018-09-17 12:13:45 +08:00
# args
2018-09-17 12:47:24 +08:00
ARG version="1.0.1"
2018-09-17 12:13:45 +08:00
ARG repo="github.com/productionwentdown/hello-world"
# source
WORKDIR $GOPATH/src/${repo}
2017-12-02 00:16:37 +08:00
COPY . .
2018-09-17 12:13:45 +08:00
# build
2017-12-02 00:16:37 +08:00
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
2018-09-17 12:13:45 +08:00
RUN go build -ldflags "-s -w" -o /hello-world
2017-12-02 00:16:37 +08:00
FROM scratch
2018-09-17 12:13:45 +08:00
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
2017-12-02 00:16:37 +08:00
EXPOSE 8080
ENTRYPOINT ["/hello-world"]