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

Assignees

No one assigned

    Labels

    needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-priorityIndicates an issue lacks a `priority/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions