Repository navigation
Description
Problem
Warm nemoclaw onboard and rebuild flows should benefit from Docker layer cache once the sandbox base image and dependencies are already present. Today, some Dockerfile structure and build-time configuration may still invalidate more layers than necessary, causing repeat builds to redo expensive work such as npm installs, OpenClaw/plugin setup, config generation, or hardening steps.
The production Dockerfile is already split from Dockerfile.base so expensive, rarely-changing layers live in the sandbox base image. This issue is about tightening the remaining derived-image layers so warm custom and default builds only rebuild the layers that truly depend on changed source, model/provider config, messaging config, or runtime metadata.
This is especially important for developers iterating on custom --from images and for maintainers validating repeated onboard/rebuild scenarios.
Scope
Identify and reduce avoidable Dockerfile cache misses in warm sandbox image builds.
Candidate areas:
- Use trace/build-step timing to identify which Dockerfile instructions are rebuilt on warm runs.
- Audit build args such as
NEMOCLAW_BUILD_ID, model/provider config, dashboard URL, messaging config, and proxy config to ensure they invalidate only the minimal required layers. - Move stable package install or verification work earlier in the Dockerfile or into base images where safe.
- Separate runtime-only or per-sandbox metadata from layers that install dependencies or patch bundled code.
- Preserve security-sensitive behavior, including fresh gateway-token generation at runtime and no secret material in layers.
- Check both default OpenClaw and Hermes sandbox Dockerfiles where the same cache-miss pattern exists.
- Add regression tests or documented manual benchmark steps for warm-build cache behavior.
Expected Behavior
After one successful build, rerunning onboard/rebuild with the same source and same effective configuration should reuse most Docker layers and spend time only on unavoidable sandbox creation/import/readiness work.
Changing runtime-only values should not force dependency installation or OpenClaw/plugin patch layers to rebuild.
Changing source, plugin code, model metadata, messaging config, or base image selection should still invalidate the layers that genuinely depend on those inputs.
Related Work
- Parent performance investigation: perf: investigate and reduce networking latency during onboard and validation #2001
- Profiling traces: perf(onboard): operationalize profiling traces for latency diagnosis #3769
- Performance budget and CI signal: perf(onboard): define onboard performance budget and CI regression signal #3776
- Custom
--fromcontext handling: perf(onboard): honor .dockerignore for custom --from build contexts #4679 - Base image resolution cache/prefetch: perf(onboard): cache and prefetch sandbox base image resolution #4680
- Cold-cache install progress and serial download UX: [WSL2][Install] fresh install + onboard takes 25-30 min with no progress feedback; sandbox image and Ollama model download run serially #3990
- Release-pinned base image refs: Publish release-pinned sandbox base image refs #4052
This issue should use #3769 trace artifacts or Docker build output to prove which warm-build steps are rebuilt before changing Dockerfile structure.
Acceptance Criteria
- Warm-build traces or build logs identify the top avoidable Dockerfile cache misses.
- At least one avoidable warm-build cache miss is removed or explicitly documented as necessary.
- Build args and
ENVpromotion are organized so per-run metadata invalidates only the minimum required layers. - Security-sensitive requirements remain intact: no raw credentials in image layers, no stale gateway auth token baked into
openclaw.json, and runtime token generation still works. - Default OpenClaw and Hermes Dockerfiles are reviewed for equivalent cache-miss patterns; fixes are applied where relevant or follow-up issues are filed.
- Tests or CI/manual benchmark guidance compare cold vs warm builds and show the expected cache reuse.
- perf: investigate and reduce networking latency during onboard and validation #2001 or perf(onboard): define onboard performance budget and CI regression signal #3776 is updated with timing evidence if the change materially improves warm onboard/rebuild time.
Non-goals
- Eliminating first-time image pulls or model downloads.
- Changing release base-image tagging policy. See Publish release-pinned sandbox base image refs #4052.
- Caching base-image resolution. See perf(onboard): cache and prefetch sandbox base image resolution #4680.
- Honoring
.dockerignorefor custom build contexts. See perf(onboard): honor .dockerignore for custom --from build contexts #4679. - Parallelizing onboard orchestration or readiness waits. See perf(onboard): parallelize safe onboard waits with cancellation handling #3775.
- Rewriting OpenShell sandbox image import behavior.
Activity
perf(docker): preserve warm sandbox build cache (#6034)
perf(docker): preserve warm sandbox build cache (NVIDIA#6034)