-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Closed
Docker build fix #4077
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
FROM golang:1.9.0-alpine3.6 AS build | ||
FROM golang:1.9.2-alpine3.6 AS build | ||
|
||
RUN apk add --no-cache --virtual git musl-dev | ||
RUN go get github.com/golang/dep/cmd/dep | ||
RUN apk add --no-cache \ | ||
git \ | ||
musl-dev \ | ||
&& go get github.com/golang/dep/cmd/dep | ||
|
||
COPY Gopkg.lock Gopkg.toml /go/src/github.com/gohugoio/hugo/ | ||
WORKDIR /go/src/github.com/gohugoio/hugo | ||
RUN dep ensure | ||
ADD . /go/src/github.com/gohugoio/hugo/ | ||
RUN dep ensure -vendor-only | ||
COPY . /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 \ | ||
|
||
RUN adduser -h /site -s /sbin/nologin -u 1000 -D hugo \ | ||
&& apk add --no-cache \ | ||
dumb-init | ||
COPY --from=build /go/bin/hugo /bin/hugo | ||
USER hugo | ||
USER hugo | ||
WORKDIR /site | ||
VOLUME /site | ||
EXPOSE 1313 | ||
VOLUME /site | ||
EXPOSE 1313 | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"] | ||
CMD [ "--help" ] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 using multiple lines and a single layer of cache here?
I find short single lines more readable personally
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.
I always use multi-line for package listing, it makes it much easier to read and also PR to review. In the offical Dockerfile best practice is a short passage about sorting multi-line, which points already in the right direction of using multi-line in general for package listing https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#sort-multi-line-arguments
I definitley agree on using a oneliner, if you just install one package, but with two I prefer to use multi-line and starting with three there is no other choice, then going multi-line.
Regarding the merge of the two layers, it is just about saving a bit of storage, few kbs, https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#minimize-the-number-of-layers and speed, because Docker doesn't have to save the intermediate layer.
And lastly it's about constistancy, if you look at the final stage of the Dockerfile, there is both used multi-line package listing and merging two layers ;)
hugo/Dockerfile
Lines 12 to 15 in 42fbf15
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.
I don't think the consistency nor the size are adding value here.
We are in the middle of the 'compilation' stage of a multi-stage build, both stages solves different problems.
At this stage, layers stays on the builder host and will never be pushed, compared to the latest stage where layers are actually pushed and where it is interesting to lower their number to gain on the image size.
At the same time, having more layers during this stage adds more steps for the user to use cache, interesting when it comes to re-building an image
However, I don't think that, in the current case, it has a significative impact, just a general thinking about guidelines and spirit of guidelines :)
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.
I think in the end it depends totally one personal taste.
The build stage is just garbage stage where you put all in, which you don't want to use in your final image, but need to make it.
And you are right, which ever approach we choose here it has almost no impact :D
So anyone else has an opinion on it? Then he/she could decide, which way to go.