diff options
author | Thibault Jamet <[email protected]> | 2017-09-07 15:17:44 +0200 |
---|---|---|
committer | Anthony Fok <[email protected]> | 2017-09-25 10:28:13 -0600 |
commit | d9697e275ecb038958b3dcea2b43e11dcba28fc9 (patch) | |
tree | e63b61afa953771a966647a6b8e96e44c7fb63eb /Dockerfile | |
parent | 09d960f17396eb7fd2c8fe6527db9503d59f0b4f (diff) | |
download | hugo-d9697e275ecb038958b3dcea2b43e11dcba28fc9.tar.gz hugo-d9697e275ecb038958b3dcea2b43e11dcba28fc9.zip |
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 <[email protected]>
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Dockerfile b/Dockerfile index ca165a986..e0da7d834 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,11 @@ 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 + +ADD vendor/vendor.json /go/src/github.com/gohugoio/hugo/vendor/vendor.json WORKDIR /go/src/github.com/gohugoio/hugo -RUN rm -f $GOPATH/bin/hugo +RUN govendor sync +ADD . /go/src/github.com/gohugoio/hugo/ RUN go install -ldflags '-s -w' FROM alpine:3.6 |