From daa4b0b4486591ba4bec3a6b9dcc8bf065e7cdb1 Mon Sep 17 00:00:00 2001 From: Vincent Composieux Date: Fri, 14 Jun 2019 19:53:00 +0200 Subject: [PATCH] Updated Dockerfile to build from scratch, decrease size from 17M to 9M --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03c118f..c6d6d88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,14 @@ RUN apk update && \ apk --no-cache add git alpine-sdk 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" WORKDIR /root/ + COPY --from=builder /go/src/github.com/eko/pihole-exporter/binary pihole-exporter CMD ["./pihole-exporter"]