From b9b68e933130b7e4072ac4cba127a636f12fc88d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 21 Dec 2018 17:06:48 -0800 Subject: [PATCH] Add multi-stage build of docker edge image (#7005) This is to reduce the overall size of the image, we only retain the binary that was built in previous stage. --- Dockerfile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb6a40494..f4483e412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,32 @@ -FROM golang:1.10.1-alpine3.7 +FROM golang:1.10.4-alpine3.7 LABEL maintainer="Minio Inc " ENV GOPATH /go -ENV PATH $PATH:$GOPATH/bin ENV CGO_ENABLED 0 + +WORKDIR /go/src/github.com/minio/ + +RUN \ + apk add --no-cache git && \ + go get -v -d github.com/minio/minio && \ + cd /go/src/github.com/minio/minio && \ + go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" + +FROM alpine:3.7 + ENV MINIO_UPDATE off ENV MINIO_ACCESS_KEY_FILE=access_key \ MINIO_SECRET_KEY_FILE=secret_key -WORKDIR /go/src/github.com/minio/ +EXPOSE 9000 +COPY --from=0 /go/bin/minio /usr/bin/minio COPY dockerscripts/docker-entrypoint.sh dockerscripts/healthcheck.sh /usr/bin/ RUN \ apk add --no-cache ca-certificates 'curl>7.61.0' && \ - apk add --no-cache --virtual .build-deps git && \ - echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ - go get -v -d github.com/minio/minio && \ - cd /go/src/github.com/minio/minio && \ - go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" && \ - rm -rf /go/pkg /go/src /usr/local/go && apk del .build-deps - -EXPOSE 9000 + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]