The problem that I wanted to solve was a long docker build time for images. I had a Go application and each time I’ve changed the source code and wanted to rebuild the image it took so much time. The issue was that the layers were wrongly defined and there was no support for Go caching mechanisms.
To reduce the time need for a build I’ve added:
- cache for
go mod download
- cache for
go build
- remove
COPY
and mount volume with sources instead - reduce data copied to docker build context