Repository navigation
feat(build): retain bounded Docker build caches safely - #1209
Merged
Merged
Conversation
This was referenced Nov 6, 2026
Open
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.
Cloud Docker builds discard their BuildKit state after every deployment, so intermediate layers and tool caches cannot be reused. This change retains project-owned cache state while continuing to remove temporary workers after success, failure, and cancellation. Generated builds use package and known compiler cache mounts on supported stock images; custom Dockerfiles and build images retain their existing command and user behavior.
Cache ownership is checked after creation and immediately before deletion. Bootstrap and collection share the physical-host provisioning lock. Attached volumes and durable pending command records protect active or unresolved workers, including lost bootstrap replies. Recovery checks legacy and current worker identities, and build completion requires confirmed command/worker exit before continuing toward cutover. Cache volumes use separate ownership labels from application data and are removed on project deletion without requiring a data-volume wipe.
Managed state has a 5 GiB host retention target, seven-day idle expiry, and LRU collection before/after builds and in the daily sweep, including hosts without projects. BuildKit receives size/free-space GC policies; Docker Engine cache is bounded separately. With a host executor, storage pressure cleans unused cache and refuses a build if insufficient space remains. Active/pinned/rollback images and application volumes are preserved. Generated session filenames no longer invalidate application COPY layers; temporary ignore-file updates are atomic and do not follow repository symlinks.
Yarn's global package archives stay in image layers because Classic and modern Plug'n'Play can require them at runtime. Yarn builds retain layer and supported build-only cache reuse. Collection sizes only idle, unprotected state to avoid walking files an active worker can remove, and project cleanup sizes only its own cache.
Validation: all 16 CI checks passed on
1578155497b22d803411fe995132bf14dd3e7235, including API, database, SDK/CLI, Actions execution, and deployment cutover/rollback suites. The real Docker suite passed cache reuse, CPU/RAM enforcement, active-cache protection, cancellation, prior-image usability after failed builds, and offline runtime tests for Yarn 1.22.22 and Yarn 4.9.2 PnP after the worker stops. Locally, 74 targeted adapter tests, adapter/API typechecks, and the error-boundary audit passed. The PR is ready, clean, and mergeable.GC limits are retention targets rather than filesystem quotas; active builds and application writes can consume space after a measurement. Tool cache mounts remain mutable during failed builds. Automatic mounts can be disabled per project or installation with
OPENSHIP_BUILD_CACHE_MOUNTS=false. Details:docs/build-cache.md.Refs #1200. This addresses general Docker cache persistence; it does not add Turbo remote-cache configuration or change monorepo installation policy.