Repository navigation
feat(sandbox): node-local package cache to speed up dependency install - #4352
Merged
Merged
Conversation
New branches provision fresh pods with an empty `emptyDir`, so every sandbox re-downloads and re-extracts its full dependency tree. Add an opt-in node-local package cache (hostPath, shared across pods on a node) so `bun install` reuses an already-populated store instead of hitting the registry each time. - chart: `depsCache` (off by default) mounts a hostPath at `/deps-cache` with a chown init container and exposes `DEPS_CACHE_ROOT`. - daemon: `depsCacheEnv()` derives `BUN_INSTALL_CACHE_DIR` per repo, keyed by the credential-stripped cloneUrl so repos never share cache entries. Measured on kind (idle node): cold install ~6s, warm (shared cache) ~3.4s. Hardlinking from the cache into node_modules is not available under K8s (the hostPath and the pod emptyDir are separate mounts → link() EXDEV), so bun falls back to copyfile; the win is the saved download + extract, not a zero-copy link.
values.yaml claimed hardlinks work under readOnlyRootFilesystem:true, but the hostPath cache and /app emptyDir are separate mounts (link() EXDEV → copyfile always). Fix the numbers and flag the hostPath DiskPressure/DoS surface. Soften the install.ts poisoning claim to name the cross-tenant public/template case and lean on bun's lockfile integrity check.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 7, 2026
PR: #4352 feat(sandbox): node-local package cache to speed up dependency install Bump type: minor - @decocms/sandbox (packages/sandbox/package.json): 1.9.8 -> 1.10.0 Deploy-Scope: both
pedrofrxncx
added a commit
that referenced
this pull request
Jul 7, 2026
#4352 added the depsCache template + values but did not bump the chart; the publish workflow skips existing versions, so 0.9.0 would never pick up the new template. Patch bump: additive, opt-in, default off.
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.
Summary
Every new branch provisions a fresh sandbox pod with an empty
emptyDirat/app, so each one re-downloads and re-extracts its entire dependency tree from the registry. This adds an opt-in, node-local package cache (a hostPath shared across sandbox pods on a node) sobun installreuses an already-populated store.Off by default — enable per environment with
depsCache.enabled=true.Changes
sandbox-env):depsCacheblock mounts a hostPath at/deps-cache(default/var/cache/studio-sandbox-deps), with a small chown init container (hostPath dirs ignorefsGroup) and aDEPS_CACHE_ROOTenv var on the sandbox container.setup/install.ts):depsCacheEnv()derivesBUN_INSTALL_CACHE_DIR=<root>/bun/<sha256(cloneUrl)>per repo. The cloneUrl is credential-stripped before hashing, so repos never share cache entries — a sandbox running untrusted code can only touch its own repo's cache (which that code could already reach via the repo itself).Measurements (kind, idle node, casaevideo-tanstack ~703MB node_modules)
Roughly halves install and eliminates registry egress on the warm path.
Honest caveats
node_moduleswhen they share a filesystem, which would make install near-instant. But the hostPath and the pod'semptyDirare separate mounts, solink()returnsEXDEVand bun falls back tocopyfile. The win is the saved download + extract, not a zero-copy link. Getting the last mile needs a prebaked read-onlynode_modulesoverlay, which is a separate design.Testing
depsCacheEnv(cache-root/cloneUrl absence, per-repo keying, credential stripping, non-URL cloneUrls).helm templateverified across guard combinations (netinit on/off × depsCache on/off).🤖 Generated with Claude Code
Summary by cubic
Adds a node-local dependency cache for sandbox pods so
bun installreuses a shared store on the same node, cutting warm install time and reducing registry egress.New Features
depsCachehostPath at/deps-cache(default/var/cache/studio-sandbox-deps) with a chown init, plusDEPS_CACHE_ROOTon the sandbox container.depsCacheEnv()sets per-repoBUN_INSTALL_CACHE_DIR=<root>/bun/<hash>from a credential‑strippedcloneUrl; an explicitBUN_INSTALL_CACHE_DIRin config still wins. kind: cold ~6s → warm ~3.4s. No hardlinking under Kubernetes (hostPath and/appemptyDirare separate mounts), so bun copies; the win is skipping download + extract.Migration
depsCache.enabled=true(optionally setdepsCache.hostPath).Written for commit 6fa9b80. Summary will update on new commits.