-
Notifications
You must be signed in to change notification settings - Fork 350
Description
Currently, the base build docker image performs multiple copies to improve build speed:
- Copy over the go.mod and go.sum files.
- go get
- copy over the rest of the files
This is done so that with docker layer caching, making a small code change doesn't result in it needing to download all dependencies. However whenever the dependencies do change, it does require a full re-download. Plus you need to run go commands locally to get the go.mod / go.sum files to update.
Go 1.5 is adding an environmental variable which allows specifying where the go mod cache is located.
I think the current double copy can be removed, and replaced with:
In the docker build commands, specify a mount of the host machine's go mod cache, and set the environment variable for the go mod cache to that mount (say, "/gomodcache")
This makes it a little more dependent on the host machine, which isn't great for docker. However it simplifies the docker files, plus go.sum is used to perform a checksum of the go mod cache files, so given the immutability here I'm not worried, and think the tradeoffs are worth it.