From 3118195e922e66235a0cc2a9fadc4f896f7bc2f7 Mon Sep 17 00:00:00 2001 From: Andrew Stone Date: Wed, 31 Aug 2016 16:32:41 -0400 Subject: [PATCH] docker: Minimize image size (#2585) This takes the image size from 823.1MB (current edge) to 281.8MB. The following steps are taken: 0) Use go-alpine for a much smaller base image 1) Perform all actions in 1 step to eliminate diff images 2) Remove unused files created after setup --- Dockerfile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c748b736a..70c801022 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ -FROM golang:1.6 +FROM golang:1.6-alpine -RUN mkdir -p /go/src/app WORKDIR /go/src/app +ENV ALLOW_CONTAINER_ROOT=1 COPY . /go/src/app -RUN go-wrapper download -RUN go-wrapper install - -ENV ALLOW_CONTAINER_ROOT=1 -RUN mkdir -p /export/docker && cp /go/src/app/docs/Docker.md /export/docker/ +RUN \ + apk add --no-cache git && \ + go-wrapper download && \ + go-wrapper install && \ + mkdir -p /export/docker && \ + cp /go/src/app/docs/Docker.md /export/docker/ && \ + rm -rf /go/pkg /go/src && \ + apk del git EXPOSE 9000 ENTRYPOINT ["go-wrapper", "run", "server"]