Quick tip to improve the docker build speed using go modules.
Normally, I would do something like this:
The problem with this approach is that, if I change any
.go file and rebuild,
it will download the dependencies again - which takes some time.
Taking into account that dependencies do not change very often, we can add just two lines and improve the build perfomance a lot:
This way, we’ll only download the dependencies again if
This can save a lot of time on local development, even more if on a slow network connection.
That’s it for today, hope it helps! 🤟