Skip to content

Commit

Permalink
Dockerfile: Reduce image size from 277MB to 27MB
Browse files Browse the repository at this point in the history
"xtrem" awesome container size optimization
by using alpine:3.6 as base image
and by installing Go at build time.

See #3730 and #3738
  • Loading branch information
ellerbrock authored and anthonyfok committed Jul 26, 2017
1 parent 606d6a8 commit bfe0bfb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Dockerfile
@@ -1,19 +1,28 @@
FROM golang:alpine3.6 FROM alpine:3.6


ENV GOPATH /go ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH


RUN \ RUN \
adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \ adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \
apk add --no-cache \ apk add --no-cache \
dumb-init \ dumb-init && \
apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
go \
git && \ git && \
mkdir -p \
${GOPATH}/bin \
${GOPATH}/pkg \
${GOPATH}/src && \
go get github.com/kardianos/govendor && \ go get github.com/kardianos/govendor && \
govendor get github.com/gohugoio/hugo && \ govendor get github.com/gohugoio/hugo && \
cd $GOPATH/src/github.com/gohugoio/hugo && \ cd $GOPATH/src/github.com/gohugoio/hugo && \
go install && \ go install && \
cd $GOPATH && \ cd $GOPATH && \
rm -rf pkg src .cache bin/govendor && \ rm -rf pkg src .cache bin/govendor && \
apk del --no-cache git go apk del .build-deps


USER hugo USER hugo
WORKDIR /site WORKDIR /site
Expand All @@ -22,4 +31,3 @@ EXPOSE 1313


ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"] ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"]
CMD [ "--help" ] CMD [ "--help" ]

0 comments on commit bfe0bfb

Please sign in to comment.