Skip to content

Comments

Update cache tags to prevent collisions#360

Merged
bschwedler merged 1 commit intomainfrom
cache-tag
Feb 20, 2026
Merged

Update cache tags to prevent collisions#360
bschwedler merged 1 commit intomainfrom
cache-tag

Conversation

@bschwedler
Copy link
Contributor

@bschwedler bschwedler commented Feb 19, 2026

@github-actions
Copy link

Test Results

1 113 tests   1 113 ✅  13m 27s ⏱️
    1 suites      0 💤
    1 files        0 ❌

Results for commit 257bb53.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates cache tag naming to prevent collisions between single-platform Docker builds by adding platform-specific suffixes. The change addresses a critical issue where single-platform builds (e.g., linux/amd64 only) would share the same cache as multi-platform builds, potentially causing build failures or incorrect cached layers.

Changes:

  • Modified cache naming to include platform suffix (e.g., -amd64) for single-platform builds while omitting it for multi-platform builds
  • Changed version regex pattern to preserve pre-release identifiers while still stripping build metadata
  • Converted cache_name from a property to a method accepting an optional platform parameter

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
posit_bakery/image/image_target.py Core logic: converted cache_name to method, added platform suffix logic, updated regex to preserve pre-release versions
posit_bakery/image/bake/bake.py Updated bake target generation to compute and pass platform parameter to cache_name
posit_bakery/config/config.py Updated build_targets to pass platforms to bake plan, fixed clean_caches to call cache_name as method
test/image/test_image_target.py Updated test to call cache_name as method with platform parameter
test/image/bake/testdata/*.json Updated expected test data to reflect new platform-specific cache tags
README.md Removed GitHub authentication requirements (repository is now public)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@ianpittwood ianpittwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this all makes sense. It's confusing how we handle platforms at the moment, but I'm also not sure how it can be improved yet.

:param dry_run: If True, print what would be deleted without actually deleting anything.
"""
target_caches = list(set([target.cache_name.split(":")[0] for target in self.targets]))
target_caches = list(set([cn.split(":")[0] for target in self.targets if (cn := target.cache_name())]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be the first time I've ever seen the walrus operator used in the real world 😆, clever way of doing it!

Comment on lines +105 to +109
cache_platform = effective_platforms[0] if len(effective_platforms) == 1 else None
cache_name = image_target.cache_name(platform=cache_platform)
if cache_name is not None:
kwargs["cache_from"] = [{"type": "registry", "ref": cache_name}]
kwargs["cache_to"] = [{"type": "registry", "ref": cache_name, "mode": "max"}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in theory, bake should handle shared caching correctly for multiplatform builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct. When we use bake, the multi-platform builds are handled natively.

@bschwedler bschwedler merged commit 1a28428 into main Feb 20, 2026
20 checks passed
@bschwedler bschwedler deleted the cache-tag branch February 20, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants