Repository navigation
feat(container): Buildx cache and driver config for build steps - #2771
Conversation
…step Adds `cache` (from/to) and `driver` (provider/opts/name) fields to the native `type: container` build step, so `docker buildx build`/`bake` invocations can import/export remote build cache and select or create a Buildx builder instance with custom driver-opts (e.g. a mirrored BuildKit image), matching what docker/build-push-action and docker/setup-buildx-action provide in GitHub Actions. Podman rejects `driver` the same way it already rejects `bake`/buildx-only config. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Adds the required blog post and roadmap milestone for the new `driver`/`cache` fields on the container build step. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughContainer build steps now support Buildx driver and cache configuration from YAML through runtime execution. Docker creates reusable builders and passes cache flags, while Podman rejects driver-backed builds. Tests, documentation, blog content, and roadmap progress were updated. ChangesBuildx driver and cache support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Workflow
participant ContainerBuild
participant DockerRuntime
participant Buildx
Workflow->>ContainerBuild: provide driver and cache configuration
ContainerBuild->>DockerRuntime: convert configuration
DockerRuntime->>Buildx: create or reuse named builder
DockerRuntime->>Buildx: run build with builder and cache flags
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
pkg/schema/workflow.go (1)
14-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider moving the sentinel error to
errors/errors.go.As per coding guidelines, static sentinel errors should be defined centrally in
errors/errors.go. WhileErrInvalidWorkflowContaineris also defined in this file (which sets a local precedent), moving them would help centralize error management.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/schema/workflow.go` around lines 14 - 16, Move the ErrInvalidContainerDriver sentinel definition from pkg/schema/workflow.go into errors/errors.go, preserving its exported name and error message; update any affected references or imports so callers continue using the same error.Source: Coding guidelines
pkg/container/docker.go (1)
94-96: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider sorting map keys for deterministic command arguments.
Iterating over
cfg.Optsdirectly results in a non-deterministic order of--driver-optarguments. While Docker Buildx handles this fine, sorting the keys (similar tojoinAttrsincommon.go) ensures the execution trace and any debug logs are fully deterministic. You will also need to add"sort"to the file imports if you apply this refactor.💡 Suggested fix
- for key, value := range cfg.Opts { - args = append(args, "--driver-opt", fmt.Sprintf(keyValueFormat, key, value)) - } + keys := make([]string, 0, len(cfg.Opts)) + for k := range cfg.Opts { + keys = append(keys, k) + } + sort.Strings(keys) + + for _, key := range keys { + args = append(args, "--driver-opt", fmt.Sprintf(keyValueFormat, key, cfg.Opts[key])) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/container/docker.go` around lines 94 - 96, Update the cfg.Opts iteration in the argument-building flow to sort its map keys before appending --driver-opt arguments, ensuring deterministic ordering in execution traces and logs; add the sort import required by this change.pkg/container/docker_test.go (1)
443-445: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
runtime.commandfor cleanup instead ofexec.Command.Calling
exec.Commanddirectly bypasses any environment configuration or specific command resolution applied internally byDockerRuntime. Usingruntime.commandensures the cleanup command behaves consistently with the rest of the runtime.💡 Suggested fix
- t.Cleanup(func() { - _ = exec.Command("docker", "buildx", "rm", cfg.Name).Run() - }) + t.Cleanup(func() { + _ = runtime.command(context.Background(), "buildx", "rm", cfg.Name).Run() + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/container/docker_test.go` around lines 443 - 445, Update the cleanup callback in the DockerRuntime test to invoke the existing runtime.command method instead of exec.Command when removing cfg.Name. Preserve the current docker buildx rm arguments and cleanup behavior while routing command resolution through runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/container/docker_test.go`:
- Around line 443-445: Update the cleanup callback in the DockerRuntime test to
invoke the existing runtime.command method instead of exec.Command when removing
cfg.Name. Preserve the current docker buildx rm arguments and cleanup behavior
while routing command resolution through runtime.
In `@pkg/container/docker.go`:
- Around line 94-96: Update the cfg.Opts iteration in the argument-building flow
to sort its map keys before appending --driver-opt arguments, ensuring
deterministic ordering in execution traces and logs; add the sort import
required by this change.
In `@pkg/schema/workflow.go`:
- Around line 14-16: Move the ErrInvalidContainerDriver sentinel definition from
pkg/schema/workflow.go into errors/errors.go, preserving its exported name and
error message; update any affected references or imports so callers continue
using the same error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f16ff4aa-fa72-4861-a8ae-733ff9b99118
📒 Files selected for processing (14)
pkg/component/container/config.gopkg/component/container/config_test.gopkg/container/common.gopkg/container/common_test.gopkg/container/docker.gopkg/container/docker_test.gopkg/container/podman.gopkg/container/podman_test.gopkg/container/runtime.gopkg/schema/container_driver_config_test.gopkg/schema/workflow.gowebsite/blog/2026-07-20-container-buildx-cache-and-driver.mdxwebsite/docs/workflows/workflows/workflow/steps/type/container.mdxwebsite/src/data/roadmap.js
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2771 +/- ##
=======================================
Coverage 81.67% 81.67%
=======================================
Files 1778 1778
Lines 170496 170565 +69
=======================================
+ Hits 139253 139317 +64
- Misses 23513 23518 +5
Partials 7730 7730
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.223.1-rc.2. |
what
driverandcachefields to the nativetype: containerbuild step (action: build)driverselects/creates the Buildx builder instance (docker buildx create), supports a bare-string shorthand (driver: docker-container) or a full form withname,provider, and driver-specificopts(e.g. a mirrored BuildKit image)cache(from/to) imports/exports Buildx remote build cache on the plain (non-bake) build path, passed through as--cache-from/--cache-toatmos, reused so create-if-missing and the builder's own cache persist across runs) and never mutates the ambient default builder — Atmos always selects it explicitly with--builderdriverthe same way it already rejectsbake/buildx-only configdriver/cacheplus three ways to avoid Docker Hub rate limits in thecontainerstep docswhy
docker/setup-buildx-action'sdriver-optsordocker/build-push-action'scache-from/cache-to, blocking migration of existing GitHub Actions Docker builds onto nativetype: containerstepsdocker-containerdriver), and pointing that builder at a mirrored BuildKit image is the cleanest way to avoid Docker Hub rate limits without changing Dockerfiles or host-level daemon configreferences
/workflows/steps/type/container#driver,/workflows/steps/type/container#cacheSummary by CodeRabbit
New Features
with.driver, supporting both shorthand and detailed driver options.with.cachewithcache.fromandcache.to.Bug Fixes
Documentation
with.driver/with.cacheexamples and Docker Hub pull-rate mitigation guidance.