Skip to content

Commit bfe0bfb

Browse files
ellerbrockanthonyfok
authored andcommitted
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
1 parent 606d6a8 commit bfe0bfb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎Dockerfile‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
FROM golang:alpine3.6
1+
FROM alpine:3.6
22

33
ENV GOPATH /go
4+
ENV PATH $GOPATH/bin:$PATH
45

56
RUN \
67
adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \
78
apk add --no-cache \
8-
dumb-init \
9+
dumb-init && \
10+
apk add --no-cache --virtual .build-deps \
11+
gcc \
12+
musl-dev \
13+
go \
914
git && \
15+
mkdir -p \
16+
${GOPATH}/bin \
17+
${GOPATH}/pkg \
18+
${GOPATH}/src && \
1019
go get github.com/kardianos/govendor && \
1120
govendor get github.com/gohugoio/hugo && \
1221
cd $GOPATH/src/github.com/gohugoio/hugo && \
1322
go install && \
1423
cd $GOPATH && \
1524
rm -rf pkg src .cache bin/govendor && \
16-
apk del --no-cache git go
25+
apk del .build-deps
1726

1827
USER hugo
1928
WORKDIR /site
@@ -22,4 +31,3 @@ EXPOSE 1313
2231

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

0 commit comments

Comments
 (0)