aboutsummaryrefslogtreecommitdiffhomepage
path: root/Dockerfile
diff options
context:
space:
mode:
authorMaik Ellerbrock <[email protected]>2017-07-26 08:51:27 +0200
committerAnthony Fok <[email protected]>2017-07-26 00:51:27 -0600
commitbfe0bfbbd1a59ddadb72a6b07fecce71716088ec (patch)
treeabe39cdf36bc2729dcc97677aef816ae39846720 /Dockerfile
parent606d6a8c9177dda4551ed198e0aabbe569f0725d (diff)
downloadhugo-bfe0bfbbd1a59ddadb72a6b07fecce71716088ec.tar.gz
hugo-bfe0bfbbd1a59ddadb72a6b07fecce71716088ec.zip
Dockerfile: Reduce image size from 277MB to 27MB
"xtrem" awesome container size optimization by using alpine:3.6 as base image and by installing Go at build time. See #3730 and #3738
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile16
1 files changed, 12 insertions, 4 deletions
diff --git a/Dockerfile b/Dockerfile
index 386fb09f1..4d6ca2db6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,19 +1,28 @@
-FROM golang:alpine3.6
+FROM alpine:3.6
ENV GOPATH /go
+ENV PATH $GOPATH/bin:$PATH
RUN \
adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \
apk add --no-cache \
- dumb-init \
+ dumb-init && \
+ apk add --no-cache --virtual .build-deps \
+ gcc \
+ musl-dev \
+ go \
git && \
+ mkdir -p \
+ ${GOPATH}/bin \
+ ${GOPATH}/pkg \
+ ${GOPATH}/src && \
go get github.com/kardianos/govendor && \
govendor get github.com/gohugoio/hugo && \
cd $GOPATH/src/github.com/gohugoio/hugo && \
go install && \
cd $GOPATH && \
rm -rf pkg src .cache bin/govendor && \
- apk del --no-cache git go
+ apk del .build-deps
USER hugo
WORKDIR /site
@@ -22,4 +31,3 @@ EXPOSE 1313
ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"]
CMD [ "--help" ]
-