Skip to content

feat(docker): optional Chromium + Xvfb pre-install in Docker image#18449

Merged
steipete merged 2 commits intoopenclaw:mainfrom
JayMishra-source:feat/chromium-docker-image
Feb 16, 2026
Merged

feat(docker): optional Chromium + Xvfb pre-install in Docker image#18449
steipete merged 2 commits intoopenclaw:mainfrom
JayMishra-source:feat/chromium-docker-image

Conversation

@JayMishra-source
Copy link
Contributor

@JayMishra-source JayMishra-source commented Feb 16, 2026

Summary

  • Adds OPENCLAW_INSTALL_BROWSER build arg to pre-install Chromium + Xvfb in the Docker image
  • Eliminates the 60-90s Playwright install that happens on every container start
  • Opt-in only — no change to default image size or behavior

Context

When browser features are enabled (headless browser tools), Chromium must be installed via Playwright. Currently this happens at runtime on every container start via custom entrypoint scripts, adding 60-90 seconds to startup time. This is especially painful on docker compose pull + restart cycles.

With this change, users who need browser features can build a variant image with Chromium pre-installed:

docker build --build-arg OPENCLAW_INSTALL_BROWSER=1 -t openclaw:browser .

The existing OPENCLAW_DOCKER_APT_PACKAGES pattern was already in place, so this follows the same opt-in build-arg convention.

Test plan

  • Build without arg → no Chromium in image (default behavior preserved)
  • Build with OPENCLAW_INSTALL_BROWSER=1 → Chromium + Xvfb installed
  • Run browser-enabled image → browser tools work without runtime install
  • Verify image size increase is ~300MB (expected for Chromium)

🤖 Generated with Claude Code

Greptile Summary

Added OPENCLAW_INSTALL_BROWSER build arg to optionally pre-install Chromium and Xvfb in the Docker image, eliminating the 60-90s Playwright installation that would otherwise occur at runtime.

Major issues found:

  • The npx playwright install command runs before pnpm install, so playwright-core won't be available in node_modules yet - this will cause the build to fail
  • Per repository guidelines, should use node /app/node_modules/playwright-core/cli.js instead of npx playwright to avoid npm override conflicts

The implementation approach is sound (follows the existing OPENCLAW_DOCKER_APT_PACKAGES pattern), but the placement and command need adjustment.

Confidence Score: 1/5

  • This PR cannot be merged as-is - it will fail during Docker build
  • The Playwright installation command runs before dependencies are installed, which will cause the Docker build to fail. This is a critical ordering issue that makes the feature non-functional.
  • Dockerfile requires the browser installation block to be moved after pnpm install

Last reviewed commit: aedf851

Adds a build arg OPENCLAW_INSTALL_BROWSER that, when set, pre-installs
Chromium (via Playwright) and Xvfb into the Docker image. This eliminates
the 60-90 second Playwright install that otherwise happens on every
container start when browser features are used.

Usage:
  docker build --build-arg OPENCLAW_INSTALL_BROWSER=1 -t openclaw:browser .

Without the build arg, behavior is unchanged (no Chromium in image).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openclaw-barnacle openclaw-barnacle bot added docker Docker and sandbox tooling size: XS labels Feb 16, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Dockerfile Outdated
Comment on lines 23 to 26
RUN if [ -n "$OPENCLAW_INSTALL_BROWSER" ]; then \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends xvfb && \
npx playwright install --with-deps chromium && \
Copy link
Contributor

Choose a reason for hiding this comment

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

npx playwright install will fail because it runs before pnpm install (line 36), so playwright-core is not yet in node_modules. This command needs to run after dependencies are installed.

Move this RUN block after line 36 (after pnpm install --frozen-lockfile).

Prompt To Fix With AI
This is a comment left during a code review.
Path: Dockerfile
Line: 23:26

Comment:
`npx playwright install` will fail because it runs before `pnpm install` (line 36), so `playwright-core` is not yet in `node_modules`. This command needs to run after dependencies are installed.

Move this RUN block after line 36 (after `pnpm install --frozen-lockfile`).

How can I resolve this? If you propose a fix, please make it concise.

Dockerfile Outdated
RUN if [ -n "$OPENCLAW_INSTALL_BROWSER" ]; then \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends xvfb && \
npx playwright install --with-deps chromium && \
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the repository's Docker docs (docs/install/docker.md:214), use node /app/node_modules/playwright-core/cli.js install chromium instead of npx playwright install to avoid npm override conflicts in Docker.

Suggested change
npx playwright install --with-deps chromium && \
node /app/node_modules/playwright-core/cli.js install --with-deps chromium && \
Prompt To Fix With AI
This is a comment left during a code review.
Path: Dockerfile
Line: 26:26

Comment:
Per the repository's Docker docs (docs/install/docker.md:214), use `node /app/node_modules/playwright-core/cli.js install chromium` instead of `npx playwright install` to avoid npm override conflicts in Docker.

```suggestion
      node /app/node_modules/playwright-core/cli.js install --with-deps chromium && \
```

How can I resolve this? If you propose a fix, please make it concise.

…/cli.js

Address review feedback:
- Move the OPENCLAW_INSTALL_BROWSER block after pnpm install so
  playwright-core is available in node_modules
- Use node /app/node_modules/playwright-core/cli.js instead of
  npx playwright to avoid npm override conflicts in Docker

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@steipete steipete merged commit 27a4868 into openclaw:main Feb 16, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments