Skip to content

container builds: opt-in extension deps via OPENCLAW_EXTENSIONS build arg#32223

Merged
vincentkoc merged 4 commits intoopenclaw:mainfrom
sallyom:dockerfile-update
Mar 6, 2026
Merged

container builds: opt-in extension deps via OPENCLAW_EXTENSIONS build arg#32223
vincentkoc merged 4 commits intoopenclaw:mainfrom
sallyom:dockerfile-update

Conversation

@sallyom
Copy link
Copy Markdown
Contributor

@sallyom sallyom commented Mar 2, 2026

Summary

  • Add OPENCLAW_EXTENSIONS build arg to the Dockerfile so users can pre-install extension npm dependencies at image build time (e.g.
    --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel matrix")
  • Wire up the build arg in docker-setup.sh and setup-podman.sh
  • Document the new option in Docker and Podman install guides
  • Add CI smoke test for the extension build arg path

Motivation

Extensions with their own package.json (33 of 41) install deps on first load at runtime. This adds a cold-start penalty in containers. With this change, users can opt in to baking those deps into the image layer for faster startup.

The 3 default extensions (device-pair, phone-control, talk-voice) have no package.json, so the default image is unchanged.

Kubernetes deployments

This change is particularly valuable for K8s environments where image immutability matters:

  • Pod churn — pods are ephemeral; every restart or scale-up would otherwise re-install extension deps from scratch
  • Air-gapped / network-restricted clusters — runtime npm install will fail if pods can't reach the npm registry
  • Startup probes — slow dep installation can cause pods to fail health checks and enter restart loops
  • Reproducibility — pre-baking deps keeps running containers identical to the built image, which is a K8s best practice for auditing and
    rollback

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

User-visible / Behavior Changes

None

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Linux, Mac
  • Runtime/container: podman, docker

Steps

  • docker build . — no extensions, same behavior as before
  • docker build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel" . — extension deps installed in image
  • podman build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel" . — same with Podman
  • CI smoke test passes for both default and extension-enabled builds

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84b2c14c0f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Dockerfile Outdated
# layer so pnpm resolves their deps before the full source copy.
# Example: docker build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel matrix" .
ARG OPENCLAW_EXTENSIONS=""
RUN --mount=type=bind,source=extensions,target=/tmp/extensions \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve non-BuildKit compatibility for Docker builds

This new RUN --mount=... instruction is BuildKit-only syntax, so builds now depend on BuildKit even when OPENCLAW_EXTENSIONS is unset. In environments that still run docker build with BuildKit disabled (for example DOCKER_BUILDKIT=0 in older CI/self-hosted setups), the Dockerfile will fail before the extension loop executes, which is a regression for the default image path. Add a fallback (or explicitly enforce BuildKit in the setup scripts/workflow) so baseline builds keep working.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@sallyom sallyom Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To work around this for plain docker, need to cp the whole extensions/ dir to a temp location, cherry-pick just the package.json files we need, then clean up. It works on both Docker (with or without BuildKit) and Podman.

The tradeoff vs the --mount approach: this adds the full extensions/ directory to the build context (not in the final image). But since the rm -rf /tmp/extensions is in the same RUN instruction, the temp files won't be included in the final layer nor in the final image.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Added OPENCLAW_EXTENSIONS build arg to enable pre-installing extension npm dependencies at image build time

  • Dockerfile: Uses bind mount to selectively copy extension package.json files before pnpm install, keeping layer size optimal
  • Setup scripts: Both docker-setup.sh and setup-podman.sh now pass the build arg correctly
  • Bonus fix: setup-podman.sh now properly forwards OPENCLAW_DOCKER_APT_PACKAGES to podman builds (was missing before)
  • Documentation: Clear examples in both Docker and Podman install guides
  • CI coverage: Added smoke test for extension build path

The approach is solid for K8s/immutable deployments where runtime npm install would fail or cause cold-start penalties.

Confidence Score: 4/5

  • Safe to merge - well-implemented optional build-time optimization with no breaking changes to default behavior
  • Implementation follows Docker best practices and existing patterns in the codebase. The feature is opt-in (default behavior unchanged), properly tested via CI smoke test, and clearly documented. Minor point: no validation of extension names in the build arg, but this is low risk since build args are controlled by the image builder.
  • No files require special attention

Last reviewed commit: 84b2c14

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation docker Docker and sandbox tooling size: XS labels Mar 2, 2026
@sallyom sallyom force-pushed the dockerfile-update branch from 84b2c14 to 8104b3c Compare March 3, 2026 15:59
@openclaw-barnacle openclaw-barnacle bot added the maintainer Maintainer-authored PR label Mar 3, 2026
@sallyom sallyom force-pushed the dockerfile-update branch 5 times, most recently from 652ec09 to 397c356 Compare March 4, 2026 20:10
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 397c35668f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Dockerfile Outdated
@sallyom sallyom force-pushed the dockerfile-update branch from 397c356 to 6e5a8bb Compare March 5, 2026 02:06
@vincentkoc
Copy link
Copy Markdown
Member

I dug into the dependency concern here because at first glance it looks like diagnostics-otel should need a direct core package dep.

What I found:

  • The missing openclaw package dependency is not the bug here.
  • Bundled extensions resolve openclaw/plugin-sdk/* through the plugin loader alias path in core, not through a direct dependencies.openclaw entry in each extension manifest.
  • OPENCLAW_EXTENSIONS is only controlling whether an extension's own npm dependencies get preinstalled into the Docker image during the early pnpm install layer.

So the distinction is:

  • openclaw/plugin-sdk/* comes from the host/core package at load time.
  • @opentelemetry/*, Matrix SDK packages, etc. come from the extension's own package.json and need to be present if we want to avoid first-load runtime installs.

That means the build arg is coherent: it is an opt-in for baking selected extension dependency trees into the image while keeping the default image smaller.

My remaining concern is CI coverage, not package metadata:

  • the new smoke path currently proves docker build succeeds and openclaw --version runs
  • it does not prove that an image built with OPENCLAW_EXTENSIONS="diagnostics-otel" can actually load that extension at runtime

So I would not treat the missing core dep as a blocker, but I do think we should either:

  • add a follow-up smoke that enables and loads diagnostics-otel in-container, or
  • explicitly accept that this PR only validates build-time preinstallation, not end-to-end extension loading

That clarification should be in the thread before merge.

@vincentkoc vincentkoc self-assigned this Mar 6, 2026
@vincentkoc vincentkoc merged commit 57f19f0 into openclaw:main Mar 6, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: acae177f0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/docker-image-digests.test.ts
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
… arg (openclaw#32223)

* Docker: opt-in extension deps via OPENCLAW_EXTENSIONS build arg

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: sallyom <[email protected]>

* CI: clarify extension smoke scope

* Tests: allow digest-pinned multi-stage FROM lines

* Changelog: note container extension preinstall option

---------

Signed-off-by: sallyom <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
… arg (openclaw#32223)

* Docker: opt-in extension deps via OPENCLAW_EXTENSIONS build arg

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: sallyom <[email protected]>

* CI: clarify extension smoke scope

* Tests: allow digest-pinned multi-stage FROM lines

* Changelog: note container extension preinstall option

---------

Signed-off-by: sallyom <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
… arg (openclaw#32223)

* Docker: opt-in extension deps via OPENCLAW_EXTENSIONS build arg

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: sallyom <[email protected]>

* CI: clarify extension smoke scope

* Tests: allow digest-pinned multi-stage FROM lines

* Changelog: note container extension preinstall option

---------

Signed-off-by: sallyom <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants