-
Notifications
You must be signed in to change notification settings - Fork 17
CLOUDP-339878 - add docker caching #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
MCK 1.3.0 Release NotesNew FeaturesMulti-Architecture SupportWe've added comprehensive multi-architecture support for the kubernetes operator. This enhancement enables deployment on IBM Power (ppc64le) and IBM Z (s390x) architectures alongside
Bug Fixes
Other Changes
|
"ref": f"{cache_registry}:cache", | ||
"mode": "max", | ||
"oci-mediatypes": "true", | ||
"image-manifest": "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""
By default, the OCI media type generates an image index for the cache image. Some OCI registries, such as Amazon ECR, don't support the image index media type: application/vnd.oci.image.index.v1+json. If you export cache images to ECR, or any other registry that doesn't support image indices, set the image-manifest parameter to true to generate a single image manifest instead of an image index for the cache image:
"""
"type": "registry", | ||
"ref": f"{cache_registry}:cache", | ||
"mode": "max", | ||
"oci-mediatypes": "true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oci is the future
cache_to = { | ||
"type": "registry", | ||
"ref": f"{cache_registry}:cache", | ||
"mode": "max", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max means we are caching all layers
return cache_from_refs, cache_to_refs | ||
|
||
|
||
def ensure_all_cache_repositories(cache_image_names: List[str], region: str = "us-east-1"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this called anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no - leftover - removed!
|
||
DEFAULT_BUILDER_NAME = "multiarch" # Default buildx builder name | ||
|
||
|
||
def ensure_ecr_cache_repository(repository_name: str, region: str = "us-east-1"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there is none - we should create the repo!
raise | ||
|
||
|
||
def build_cache_configuration(base_registry: str) -> tuple[list[Any], dict[str, str]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some gotchas:
- its one cache per image
- every cache tag has one manifest which gets overwritten
- thus, i've added a dedicated cache tag per branch but always read from master and push to master on master merges (more info here and here and a really good blog post)
Summary
This pull request introduces a new branch and cache scoping system for Docker BuildKit remote cache in CI and local development environments. It adds robust branch detection and cache scope generation logic, integrates these into the image build process, and provides comprehensive unit tests to ensure correctness. The main goal is to enable per-branch and per-patch caching for Docker builds, improving build performance and cache isolation.
Branch and cache scoping infrastructure:
scripts/release/branch_detection.py
with functions to detect the current git branch and generate sanitized cache scope strings for use in BuildKit caching, supporting both local development and Evergreen CI environments.Integration with image build process:
scripts/release/build/image_build_process.py
to use the new branch and cache scope utilities for configuring BuildKit cache, including logic to set up per-branch/per-patch cache repositories and read/write precedence (branch → master).Proof of Work
Checklist
skip-changelog
label if not needed