Skip to content

Optimize go build caching in release-binary make target #13408

@Dhairya-Arora01

Description

@Dhairya-Arora01

The release-binary Makefile target currently uses /tmp/ as the GOCACHE directory inside the Docker container, which means the build cache is discarded after every run. This results in slower builds since Go has to recompile everything from scratch each time.

The make target release-binaries build the clusterctl binary for each architecture by calling the release-binary target. Therefore, the same go packages are installed each and every time and recompilation from scratch occurs every time which is bit inefficient.

Changes proposed:

  • Set GOCACHE to /go/build-cache/ instead of /tmp/
  • Mount the host's GOMODCACHE into the container at /go/pkg/mod to reuse downloaded modules.
  • Mount the host's GOCACHE into the container at /go/build-cache to persist the build cache across runs.

These volume mounts allow the Docker build to leverage caches from the host machine, significantly speeding up incremental builds.

Metadata

Metadata

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.priority/backlogHigher priority than priority/awaiting-more-evidence.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions