mirror of https://github.com/linkerd/linkerd2.git
The way that git-related version information is linked into go binaries busts Docker's cache such that every commit causes all binaries to rebuilt. In order to ameliorate this, we can build each binary once without version information first so that its artifacts are cached. When Go sources are not changed and only the version information changes, builds are 4.3x faster than before (from 5+ minutes to <90s). On `master` Branch off of master and build (mostly cached): ``` :; time DOCKER_TRACE=1 bin/docker-build ... DOCKER_TRACE=1 bin/docker-build 9.10s user 6.30s system 5% cpu 4:26.47 total ``` Rebuild without changing anything (highly cached): ``` :; time DOCKER_TRACE=1 bin/docker-build ... DOCKER_TRACE=1 bin/docker-build 9.23s user 6.04s system 47% cpu 32.017 total ``` Update only the git sha and rebuild: ``` :; git ci -am 'bump it' --allow-empty [ver/eg 2749eb3] bump it :; time DOCKER_TRACE=1 bin/docker-build ... DOCKER_TRACE=1 bin/docker-build 8.55s user 6.08s system 4% cpu 5:22.25 total ``` On this branch: Rebuild without changing anything (highly cached): ``` :; time DOCKER_TRACE=1 bin/docker-build ... DOCKER_TRACE=1 bin/docker-build 8.94s user 5.97s system 46% cpu 32.257 total ``` Update only the git sha and rebuild: ``` :; git ci -am 'bump it' --allow-empty [ver/go-docker-cache-versionless 77a80b5] bump it :; time DOCKER_TRACE=1 bin/docker-build ... DOCKER_TRACE=1 bin/docker-build-cli-bin 2.02s user 1.34s system 9% cpu 34.144 total ``` |
||
---|---|---|
.. | ||
api | ||
cmd | ||
destination | ||
gen | ||
k8s | ||
script | ||
tap | ||
util | ||
Dockerfile |