ci: explore --cache-from and leverage multi-stage builds to speed up builds
Created by: jhchabran
Follow up on https://github.com/sourcegraph/sourcegraph/pull/31066 that leverage explicit caching with --cache-from
and pushes individual stages to avoid rebuilding them later.
Please note that this PR does not make use of our internal docker registry because we need to either add the missing certificates to enable https
or configure the dind
container to make an exception and use our internal registry to pull things with insecure settings.
Apparently, it's totally fine when using it as a pull-through, but not when pushing onto it explicitly.
As a result, we went from 6m30 for a gitserver
build on the stateless agents down to 2m30 (30s are just for cloning the repo). It's going to be marginally faster by using our own registry rather than pushing on gcr, but I don't think that's going to shave a ton either.
The process to handle the caching explicitly is rather repetitive, especially if with multi-stage builds, but that could be addressed through scripting.