-
Notifications
You must be signed in to change notification settings - Fork 7.6k
docs: use bind mounts in Go Dockerfile examples #22388
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
UPDATE: I have removed the
Using the https://github.com/github/github-mcp-server Go application as an example below. Size of
Size of
Running |
Signed-off-by: Eng Zer Jun <[email protected]>
`go build` will automatically download module dependencies. In many cases, that is a much smaller set of modules than what is downloaded by `go mod download`. Using the https://github.com/github/github-mcp-server Go application as an example below. Size of GOMODCACHE with `go mod download`: $ go clean -i -r -cache -modcache $ go mod download $ du -sh ~/go/pkg/mod 186M /home/jun/go/pkg/mod Size of GOMODCACHE with `go build`: $ go clean -i -r -cache -modcache $ CGO_ENABLED=0 go build -ldflags="-s -w" cmd/github-mcp-server/main.go go: downloading github.com/spf13/viper v1.20.1 go: downloading github.com/mark3labs/mcp-go v0.18.0 go: downloading github.com/google/go-github/v69 v69.2.0 go: downloading github.com/sirupsen/logrus v1.9.3 go: downloading github.com/spf13/cobra v1.9.1 go: downloading golang.org/x/sys v0.31.0 go: downloading github.com/spf13/afero v1.14.0 go: downloading github.com/fsnotify/fsnotify v1.8.0 go: downloading github.com/spf13/cast v1.7.1 go: downloading github.com/go-viper/mapstructure/v2 v2.2.1 go: downloading github.com/subosito/gotenv v1.6.0 go: downloading gopkg.in/yaml.v3 v3.0.1 go: downloading github.com/spf13/pflag v1.0.6 go: downloading github.com/pelletier/go-toml/v2 v2.2.3 go: downloading github.com/sagikazarmark/locafero v0.9.0 go: downloading golang.org/x/text v0.23.0 go: downloading github.com/google/uuid v1.6.0 go: downloading github.com/yosida95/uritemplate/v3 v3.0.2 go: downloading github.com/sourcegraph/conc v0.3.0 go: downloading github.com/google/go-querystring v1.1.0 $ du -sh ~/go/pkg/mod 80M /home/jun/go/pkg/mod Reference: https://stackoverflow.com/a/68172023/7902371 Signed-off-by: Eng Zer Jun <[email protected]>
@aevesdocker @crazy-max Hi, would you mind giving this PR a quick review when you have time? Thanks a lot 🙏 |
Description
I remembered there used to be a page (https://docs.docker.com/build/guide/mounts/) that demonstrated how to use both bind mounts and cache mounts together in a Dockerfile for a Go application. However, that page was removed in #20715, and the new page (https://docs.docker.com/build/cache/optimize/) now separates the examples for bind mounts and cache mounts.
docs/content/build/guide/mounts.md
Lines 185 to 194 in 91b324f
It would be great if the remaining Go Dockerfile examples could show how to use both bind mounts and cache mounts together
specifically for(See #22388 (comment) for updtae)go.mod
andgo.sum
. This combination was really helpful for improving build performance and clarity when using Docker for Go development.Related issues or tickets
Reviews