From 16544b458109c9ea938757e929e75387e91fedf6 Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Thu, 28 Sep 2017 12:49:02 +0200 Subject: [PATCH] Remove build deps after build This shrinks the docker image from 300+ MB to 14 MB. --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37234d9..0fce4a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,11 @@ FROM alpine:latest EXPOSE 9130 -RUN apk update ; apk add go ; apk add git ; apk add musl-dev ; \ - go get github.com/mdlayher/unifi_exporter/cmd/unifi_exporter; \ - mv ~/go/bin/unifi_exporter /bin/ +RUN apk add --update --virtual build-deps go git musl-dev && \ + go get github.com/mdlayher/unifi_exporter/cmd/unifi_exporter && \ + mv ~/go/bin/unifi_exporter /bin/ && \ + apk del build-deps && \ + rm -rf /var/cache/apk/* ~/go/ USER nobody ENTRYPOINT ["/bin/unifi_exporter"]