1
0
Fork 0

Update Dockerfile

master 1.0.0
Ambrose Chua 2018-09-17 12:05:51 +08:00 committed by GitHub
parent 4911e597db
commit 7cac148936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 12 deletions

View File

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