mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Update Dockerfile to benefit build cache
Docker has recently introduces buikld-stages (as of version 17.05) Build stages allows to benefit the docker build cache as well as reducing the size of the resulting image c.f. https://docs.docker.com/engine/userguide/eng-image/multistage-build/ This change allows to have faster builds when running `docker build` several times after changing some little code Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
This commit is contained in:
parent
a3a3f5b861
commit
09d960f173
1 changed files with 11 additions and 23 deletions
34
Dockerfile
34
Dockerfile
|
@ -1,30 +1,18 @@
|
||||||
|
FROM golang:1.9.0-alpine3.6 AS build
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual git musl-dev
|
||||||
|
RUN go get github.com/kardianos/govendor
|
||||||
|
RUN govendor get github.com/gohugoio/hugo
|
||||||
|
WORKDIR /go/src/github.com/gohugoio/hugo
|
||||||
|
RUN rm -f $GOPATH/bin/hugo
|
||||||
|
RUN go install -ldflags '-s -w'
|
||||||
|
|
||||||
FROM alpine:3.6
|
FROM alpine:3.6
|
||||||
|
|
||||||
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 \
|
COPY --from=build /go/bin/hugo /bin/hugo
|
||||||
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 && \
|
|
||||||
rm -f $GOPATH/bin/hugo && \
|
|
||||||
go install -ldflags '-s -w' && \
|
|
||||||
cd $GOPATH && \
|
|
||||||
rm -rf pkg src .cache bin/govendor && \
|
|
||||||
apk del .build-deps
|
|
||||||
|
|
||||||
USER hugo
|
USER hugo
|
||||||
WORKDIR /site
|
WORKDIR /site
|
||||||
VOLUME /site
|
VOLUME /site
|
||||||
|
|
Loading…
Reference in a new issue