When building images which require buildkit features the standard docker driver caching becomes unavailable.
There are a couple workarounds at the moment, with the primary one being caching in a repository. This is feasible only when the the repository in question already exists, which in case of e.g. CDK is not the case on initial build, plus it doesn't give you access to latest tags anyway.
The way we are currently working around it is to --cache-to=type=local to a known directory, and then utilize a defined cache in bitbucket-pipelines.yml to cache that directory, with the Dockerfile being the key. Since our layers cache maxes out at around 80-100MB uncompressed, this works okay'ish, but obviously invalidates all caches when something in a later step in the Dockerfile changes, which should not affect previous layers.
Now here's my recommendation:
Buildkit already has a cache backend for the GitHub Actions cache, so it can immediately directly communicate with the cache. Bitbucket could implement the GitHub Actions cache protocol in its cache, which would allow to use tha gha cache type directly, no changes required upstream.
Alternatively, Atlassian could contribute a cache backend for their Bitbucket Pipelines cache to Buildkit (e.g. type=bp), which would allow docker to immediately cache from and to the Bitbucket cache.
Considering that buildx is becoming the standard, an out-of-the-box caching solution should be found.
Hi Ben,
Thank you for the suggestions!
We have a feature request in our issue tracker for caching layers produced when using BuildKit:
I went ahead and added a comment with a link to your post and I also quoted your feedback. You can add your vote to that feature request (by selecting the Vote for this issue link). You are more than welcome to leave a comment if you have any additional feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.
Implementation of features is done as per our policy here and any updates will be posted in the feature request.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.