Skip to content

feat(container): Buildx cache and driver config for build steps - #2771

Merged
Andriy Knysh (aknysh) merged 3 commits into
mainfrom
osterman/buildkit-driver-opts-support
Jul 21, 2026
Merged

Andriy Knysh (aknysh) merged 3 commits into
mainfrom
osterman/buildkit-driver-opts-support

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

what

  • Add driver and cache fields to the native type: container build step (action: build)
  • driver selects/creates the Buildx builder instance (docker buildx create), supports a bare-string shorthand (driver: docker-container) or a full form with name, provider, and driver-specific opts (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-to
  • Builder creation is idempotent (a stable default name of atmos, 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 --builder
  • Podman rejects driver the same way it already rejects bake/buildx-only config
  • Adds the required blog post and roadmap milestone, and documents driver/cache plus three ways to avoid Docker Hub rate limits in the container step docs

why

  • The native container build step had no equivalent to docker/setup-buildx-action's driver-opts or docker/build-push-action's cache-from/cache-to, blocking migration of existing GitHub Actions Docker builds onto native type: container steps
  • Remote cache import/export needs a Buildx builder capable of exporting cache (the docker-container driver), 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 config

references

  • Related docs: /workflows/steps/type/container#driver, /workflows/steps/type/container#cache

Summary by CodeRabbit

  • New Features

    • Added Buildx builder configuration (including named builder selection/creation) via with.driver, supporting both shorthand and detailed driver options.
    • Added Buildx build cache import/export via with.cache with cache.from and cache.to.
  • Bug Fixes

    • Podman runtime now fails earlier when a Docker Buildx driver is provided, with a clearer unsupported-driver error.
  • Documentation

    • Updated container build step docs with with.driver/with.cache examples and Docker Hub pull-rate mitigation guidance.
    • Added a blog post explaining Buildx cache and driver usage.

…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]>
@atmos-pro

atmos-pro Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Jul 20, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Jul 20, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 96bf15c8-8d4b-4788-8be1-96cffca8cac6

📥 Commits

Reviewing files that changed from the base of the PR and between 36009a3 and c7ecf1c.

📒 Files selected for processing (2)
  • pkg/container/runtime.go
  • pkg/schema/workflow.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/schema/workflow.go

📝 Walkthrough

Walkthrough

Container 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.

Changes

Buildx driver and cache support

Layer / File(s) Summary
Schema and runtime configuration contracts
pkg/schema/workflow.go, pkg/schema/container_driver_config_test.go, pkg/container/runtime.go, pkg/component/container/config.go, pkg/component/container/config_test.go
Build steps decode scalar or mapping driver values and cache entries, then map them into runtime DriverConfig and CacheConfig values.
Buildx argument composition
pkg/container/common.go, pkg/container/common_test.go
Build and bake commands receive effective builder names; Buildx builds also receive serialized cache import and export arguments.
Docker builder lifecycle and runtime guards
pkg/container/docker.go, pkg/container/docker_test.go, pkg/container/podman.go, pkg/container/podman_test.go
Docker creates or reuses named Buildx builders, while Podman rejects driver-backed configurations.
Usage documentation and project status
website/docs/workflows/workflows/workflow/steps/type/container.mdx, website/blog/2026-07-20-container-buildx-cache-and-driver.mdx, website/src/data/roadmap.js
Documentation covers driver, cache, builder, and registry-mirroring configuration; roadmap progress changes from 67 to 75.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Buildx cache and driver config for container build steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/buildkit-driver-opts-support

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
pkg/schema/workflow.go (1)

14-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider moving the sentinel error to errors/errors.go.

As per coding guidelines, static sentinel errors should be defined centrally in errors/errors.go. While ErrInvalidWorkflowContainer is 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 value

Consider sorting map keys for deterministic command arguments.

Iterating over cfg.Opts directly results in a non-deterministic order of --driver-opt arguments. While Docker Buildx handles this fine, sorting the keys (similar to joinAttrs in common.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 value

Use runtime.command for cleanup instead of exec.Command.

Calling exec.Command directly bypasses any environment configuration or specific command resolution applied internally by DockerRuntime. Using runtime.command ensures 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6325b89 and 36009a3.

📒 Files selected for processing (14)
  • pkg/component/container/config.go
  • pkg/component/container/config_test.go
  • pkg/container/common.go
  • pkg/container/common_test.go
  • pkg/container/docker.go
  • pkg/container/docker_test.go
  • pkg/container/podman.go
  • pkg/container/podman_test.go
  • pkg/container/runtime.go
  • pkg/schema/container_driver_config_test.go
  • pkg/schema/workflow.go
  • website/blog/2026-07-20-container-buildx-cache-and-driver.mdx
  • website/docs/workflows/workflows/workflow/steps/type/container.mdx
  • website/src/data/roadmap.js

@codecov

codecov Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.14286% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.67%. Comparing base (54a79c0) to head (c7ecf1c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/container/docker.go 53.33% 4 Missing and 3 partials ⚠️
pkg/schema/workflow.go 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           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           
Flag Coverage Δ
unittests 81.67% <87.14%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/component/container/config.go 94.79% <100.00%> (+0.44%) ⬆️
pkg/container/common.go 95.00% <100.00%> (+0.39%) ⬆️
pkg/container/podman.go 79.05% <100.00%> (ø)
pkg/container/runtime.go 100.00% <ø> (ø)
pkg/schema/workflow.go 98.99% <88.23%> (-1.01%) ⬇️
pkg/container/docker.go 77.88% <53.33%> (-1.21%) ⬇️

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aknysh
Andriy Knysh (aknysh) merged commit bdf8db7 into main Jul 21, 2026
78 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/buildkit-driver-opts-support branch July 21, 2026 00:39
@atmos-pro

atmos-pro Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.223.1-rc.2.

This branch was successfully deployed

1 active deployment
preview — c7ecf1cf Deployed Jul 20, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants