Updated Dockerfile to build from scratch, decrease size from 17M to 9M

This commit is contained in:
Vincent Composieux 2019-06-14 19:53:00 +02:00
parent eb938db545
commit daa4b0b448
No known key found for this signature in database
GPG key ID: 7306974ABA6382AC

View file

@ -7,13 +7,14 @@ RUN apk update && \
apk --no-cache add git alpine-sdk apk --no-cache add git alpine-sdk
RUN GO111MODULE=on go mod vendor RUN GO111MODULE=on go mod vendor
RUN GOOS=linux go build -o binary ./ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-w' -o binary ./
FROM alpine FROM scratch
LABEL name="pihole-exporter" LABEL name="pihole-exporter"
WORKDIR /root/ WORKDIR /root/
COPY --from=builder /go/src/github.com/eko/pihole-exporter/binary pihole-exporter COPY --from=builder /go/src/github.com/eko/pihole-exporter/binary pihole-exporter
CMD ["./pihole-exporter"] CMD ["./pihole-exporter"]