Repository navigation
feat(cli): add --cache-from and --cache-to options to cartesi build - #485
Open
endersonmaia wants to merge 2 commits into
Open
endersonmaia wants to merge 2 commits into
endersonmaia wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 0933509 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
📁 File Coverage (20 files)
|
tuler
reviewed
Jun 4, 2026
endersonmaia
force-pushed
the
feature/add-cache-options-to-build
branch
from
June 8, 2026 19:11
1790c3a to
f05974e
Compare
Member
|
@endersonmaia can you rebase that so we can merge it? |
endersonmaia
force-pushed
the
feature/add-cache-options-to-build
branch
from
October 19, 2026 13:03
f05974e to
05479fe
Compare
endersonmaia
force-pushed
the
feature/add-cache-options-to-build
branch
from
October 19, 2026 13:06
05479fe to
8c93f37
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The cache flag accumulators fail type checking, and the recovery test can pass without exercising cache import.
2 open issues
What changed in this PR
Adds Docker Buildx cache configuration to cartesi build, supporting cache reuse in CI as requested in #483.
Changes:
- Adds repeatable cache flags that override per-drive TOML settings.
- Passes cache specifications to Docker Buildx.
- Adds parsing and cache integration tests, plus a release note.
| File | Description |
|---|---|
| apps/cli/tests/unit/config.test.ts | Tests TOML cache parsing and defaults. |
| apps/cli/tests/integration/builder/fixtures/Dockerfile.cache | Adds a timestamp layer to detect cache reuse. |
| apps/cli/tests/integration/builder/docker.test.ts | Tests local cache export and recovery. |
| apps/cli/src/config.ts | Defines and parses per-drive cache settings. |
| apps/cli/src/commands/build.ts | Adds cache flags and override handling. |
| apps/cli/src/builder/docker.ts | Forwards cache options to Buildx. |
| .changeset/cache-options-for-build.md | Documents the CLI feature for release. |
Review effort: Balanced
Expose Docker Buildx cache backend specs via two new repeatable CLI flags:
cartesi build --cache-from type=local,src=/tmp/cache \
--cache-to type=local,dest=/tmp/cache
The same options are also available per-drive in cartesi.toml:
[drives.root]
cache_from = ["type=gha"]
cache_to = ["type=gha,mode=max"]
CLI flags override the TOML values when non-empty.
Changes:
- config.ts: add cacheFrom/cacheTo fields to DockerDriveConfig and
defaultRootDriveConfig; parse cache_from/cache_to from TOML
- builder/docker.ts: thread cacheFrom/cacheTo through ImageBuildOptions
and append --cache-from / --cache-to args to the buildx invocation
- commands/build.ts: add --cache-from and --cache-to options (accumulator
style); merge into BuildContext and apply over per-drive config
- tests/unit/config.test.ts: add assertion for cache_from/cache_to parsing
- tests/integration/builder/docker.test.ts: add two integration tests —
one verifying the local cache directory is written, one verifying that
layers are recovered from a local cache after the daemon build cache is
pruned (attested by comparing root.ext2 SHA-256 between the two builds)
- tests/integration/builder/fixtures/Dockerfile.cache: new fixture using
a non-deterministic RUN date layer to make cache-hit vs miss detectable
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
endersonmaia
force-pushed
the
feature/add-cache-options-to-build
branch
from
October 20, 2026 12:04
8c93f37 to
c2ad3d4
Compare
tuler
approved these changes
Oct 20, 2026
tuler
left a comment
Member
There was a problem hiding this comment.
recommend waiting for SDK release before merging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This pull request adds support for Docker Buildx cache options to the
cartesi buildcommand, allowing users to specify cache sources and destinations for Docker builds. The changes introduce new--cache-fromand--cache-toCLI flags, update the configuration parsing logic to support these options incartesi.toml, and add comprehensive tests to ensure correct behavior.Docker Buildx cache support:
--cache-from <spec>and--cache-to <spec>CLI flags to thecartesi buildcommand, allowing users to specify Docker Buildx cache sources and destinations. These flags are repeatable and override any values set incartesi.toml. [1] [2]DockerDriveConfigtype and configuration parsing to supportcacheFromandcacheToarrays, both in code defaults and when reading fromcartesi.toml. [1] [2] [3] [4]--cache-fromand--cache-tooptions to Docker Buildx when building images. [1] [2] [3] [4]Testing and validation:
cache_fromandcache_tooptions from configuration files. [1] [2]These changes improve build performance and reproducibility by enabling advanced Docker caching strategies in both CLI usage and configuration files.
/closes #483