Skip to content

Commit d9697e2

Browse files
tjametanthonyfok
authored andcommitted
Split go build in Dockerfile
To maximize the usage of cache, split the govendor get in steps: - govendor fetch to get the pinned versions of dependencies - go install to actually build the binary Doing so allows not to re-download the whole dependencies when changing lines in hugo repository The current Dockerfile generates an image of 16.6MB Signed-off-by: Thibault Jamet <tjamet@users.noreply.github.com>
1 parent 09d960f commit d9697e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎Dockerfile‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ FROM golang:1.9.0-alpine3.6 AS build
22

33
RUN apk add --no-cache --virtual git musl-dev
44
RUN go get github.com/kardianos/govendor
5-
RUN govendor get github.com/gohugoio/hugo
5+
6+
ADD vendor/vendor.json /go/src/github.com/gohugoio/hugo/vendor/vendor.json
67
WORKDIR /go/src/github.com/gohugoio/hugo
7-
RUN rm -f $GOPATH/bin/hugo
8+
RUN govendor sync
9+
ADD . /go/src/github.com/gohugoio/hugo/
810
RUN go install -ldflags '-s -w'
911

1012
FROM alpine:3.6

0 commit comments

Comments
 (0)