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

cmd.go: why we use go mod download before build go application? #40242

Closed
4orty opened this issue Jul 16, 2020 · 2 comments
Closed

cmd.go: why we use go mod download before build go application? #40242

4orty opened this issue Jul 16, 2020 · 2 comments

Comments

@4orty
Copy link

@4orty 4orty commented Jul 16, 2020

What version of Go are you using (go version)?

$ go version
1.14

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

When people make dockerfile of go application with module, most of them make like this.

FROM golang
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go build

But when i tested like below, it also works well.

FROM golang
COPY . .
RUN go build

what's the difference?
If i use go mod download command, can i get some advantages?

What did you expect to see?

What did you see instead?

@davecheney
Copy link
Contributor

@davecheney davecheney commented Jul 16, 2020

Thank you for raising this issue. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

@davecheney davecheney closed this Jul 16, 2020
@agnivade
Copy link
Contributor

@agnivade agnivade commented Jul 19, 2020

Presumably, it's about creating extra docker layers so that small changes don't make a big difference in the re-build time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.