Browse files

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 <>
  • Loading branch information...
tjamet authored and anthonyfok committed Sep 7, 2017
1 parent 09d960f commit d9697e275ecb038958b3dcea2b43e11dcba28fc9
Showing with 4 additions and 2 deletions.
  1. +4 −2 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
RUN govendor get
ADD vendor/vendor.json /go/src/
WORKDIR /go/src/
RUN rm -f $GOPATH/bin/hugo
RUN govendor sync
ADD . /go/src/
RUN go install -ldflags '-s -w'
FROM alpine:3.6

0 comments on commit d9697e2

Please sign in to comment.