Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build fix #4077

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ RUN apk add --no-cache --virtual git musl-dev
RUN go get github.com/golang/dep/cmd/dep

WORKDIR /go/src/github.com/gohugoio/hugo
RUN dep ensure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally opt for adding Gopkg.* and running dep ensure -vendor-only instead of dep ensure.
Reason being that dep ensure takes a while (see https://github.com/golang/dep/blob/master/docs/FAQ.md#why-is-dep-slow) and that by nature, dep locks dependencies in a well-known file. We expect the dependencies lock to evolve less often than the code itself hence we can benefit docker build cache when re-building the image after hugo code update.

the following patch works for me:

diff --git i/Dockerfile w/Dockerfile
index 889584b6..119a972f 100644
--- i/Dockerfile
+++ w/Dockerfile
@@ -3,8 +3,9 @@ FROM golang:1.9.0-alpine3.6 AS build
 RUN apk add --no-cache --virtual git musl-dev
 RUN go get github.com/golang/dep/cmd/dep

+ADD Gopkg.* /go/src/github.com/gohugoio/hugo/
 WORKDIR /go/src/github.com/gohugoio/hugo
-RUN dep ensure
+RUN dep ensure -vendor-only
 ADD . /go/src/github.com/gohugoio/hugo/
 RUN go install -ldflags '-s -w'

ADD . /go/src/github.com/gohugoio/hugo/
RUN dep ensure
RUN go install -ldflags '-s -w'

FROM alpine:3.6
Expand Down