Skip to content

perf(onboard): reduce Dockerfile cache misses in warm sandbox builds #4682

Description

@ahunnargikar-nvidia

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

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 ENV promotion 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

Activity

  1. added
    area: cli
    area: packaging
    enhancement
    platform: container
    area: performance
    and removed on Jun 3, 2026
  2. removed
    enhancement
    on Jun 8, 2026
  3. added a commit that references this issue on Jun 30, 2026
    37a8094
  4. added a commit that references this issue on Jul 12, 2026
    df789db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cliarea: packagingarea: performanceplatform: container

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions