Optimized container image size

REPOSITORY                 TAG      SIZE
guessi/ssl-certs-checker   dev      12.5MB (31% reduced)
guessi/ssl-certs-checker   latest   17.9MB
This commit is contained in:
guessi 2020-05-10 16:21:45 +08:00
parent 90de2658f9
commit d80e324241

View File

@ -1,10 +1,13 @@
FROM golang:1.14-alpine3.11 AS builder
RUN apk add --no-cache git
LABEL maintainer="guessi <guessi@gmail.com>"
RUN apk add --no-cache git ca-certificates
WORKDIR ${GOPATH}/src/github.com/guessi/ssl-certs-checker
COPY . .
RUN go build -o /go/bin/ssl-certs-checker
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /go/bin/ssl-certs-checker
FROM alpine:3.11
FROM scratch
LABEL maintainer="guessi <guessi@gmail.com>"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/bin/ssl-certs-checker /opt/
WORKDIR /opt/
ENTRYPOINT ["/opt/ssl-certs-checker"]