Skip to content

feat: switch from GitLab caching to Registry caching for docker builds

Looking for performance improvements, this switches from GitLab CI tasks to registry cache provider.

Using native image caches is likely to be faster: see https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/instrumentor/-/merge_requests/4314 for real-world results.

@jburnitz reported 15-20 minutes just to push and pull files from the cache using GitLab caching: https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/instrumentor/-/jobs/8199915708#L909

Caching

By default, caching is enabled for Docker tasks.

Caching will store cache images in the $CI_REGISTRY_IMAGE/cache registry. All cache tags start with the prefix of cache- to allow for easy cleanup.

Two cache key schemes are used:

  1. BRANCH_REGISTRY_CACHE_KEY for branches
  2. DEFAULT_BRANCH_REGISTRY_CACHE_KEY - for default branch.

Please review the template definition for details, but these can be overridden depending on project requirements.

There are three caching modes:

  1. For branches: docker buildx will read from the branch cache and the default branch cache, and write the branch cache.
  2. For main branch: docker buildx will read from and write to the default branch cache.
  3. For tags: docker buildx will read from the default branch cache and not write to the cache.

cc @jburnitz

Edited by Andrew Newdigate

Merge request reports

Loading