-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix(dockerfile): bugfix for broken docker build + optimization #4154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
FROM golang:1.9.0-alpine3.6 AS build | ||
# GitHub: https://github.com/gohugoio/ | ||
# Docker: https://hub.docker.com/r/gohugoio/ | ||
# Twitter: https://twitter.com/gohugoio | ||
|
||
RUN apk add --no-cache --virtual git musl-dev | ||
RUN go get github.com/golang/dep/cmd/dep | ||
FROM golang:1.10-rc-alpine3.7 AS build | ||
|
||
WORKDIR /go/src/github.com/gohugoio/hugo | ||
RUN dep ensure | ||
ADD . /go/src/github.com/gohugoio/hugo/ | ||
RUN go install -ldflags '-s -w' | ||
|
||
FROM alpine:3.6 | ||
RUN \ | ||
adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \ | ||
apk add --no-cache \ | ||
dumb-init | ||
git \ | ||
musl-dev && \ | ||
go get github.com/golang/dep/cmd/dep && \ | ||
go get github.com/kardianos/govendor && \ | ||
govendor get github.com/gohugoio/hugo && \ | ||
cd /go/src/github.com/gohugoio/hugo && \ | ||
dep ensure && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although you consider it breaks docker best practices, you may consider that doing this requires re-building It is okay when the build step is built by a remote server that always discards cache, but might be interesting when iterating on As suggested in #4077 distinguishing installing dependent tools, dependencies and actual binary generation allows to benefit the docker build cache while building the image.
considers that:
|
||
go install -ldflags '-s -w' | ||
|
||
# --- | ||
|
||
FROM alpine:3.7 | ||
|
||
COPY --from=build /go/bin/hugo /bin/hugo | ||
|
||
RUN \ | ||
adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \ | ||
apk add --no-cache dumb-init | ||
|
||
USER hugo | ||
WORKDIR /site | ||
VOLUME /site | ||
EXPOSE 1313 | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"] | ||
ENTRYPOINT [ "/usr/bin/dumb-init", "--", "hugo" ] | ||
CMD [ "--help" ] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not relying on the current working directory?
Wouldn't it be something interesting to be able to generate an image from the current directory (for development or testing for example)?