feat(docker): optional Chromium + Xvfb pre-install in Docker image#18449
Merged
steipete merged 2 commits intoopenclaw:mainfrom Feb 16, 2026
Merged
feat(docker): optional Chromium + Xvfb pre-install in Docker image#18449steipete merged 2 commits intoopenclaw:mainfrom
steipete merged 2 commits intoopenclaw:mainfrom
Conversation
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]>
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 && \ |
Contributor
There was a problem hiding this 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).
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 && \ |
Contributor
There was a problem hiding this 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.
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]>
18 tasks
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
OPENCLAW_INSTALL_BROWSERbuild arg to pre-install Chromium + Xvfb in the Docker imageContext
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_PACKAGESpattern was already in place, so this follows the same opt-in build-arg convention.Test plan
OPENCLAW_INSTALL_BROWSER=1→ Chromium + Xvfb installed🤖 Generated with Claude Code
Greptile Summary
Added
OPENCLAW_INSTALL_BROWSERbuild 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:
npx playwright installcommand runs beforepnpm install, soplaywright-corewon't be available innode_modulesyet - this will cause the build to failnode /app/node_modules/playwright-core/cli.jsinstead ofnpx playwrightto avoid npm override conflictsThe implementation approach is sound (follows the existing
OPENCLAW_DOCKER_APT_PACKAGESpattern), but the placement and command need adjustment.Confidence Score: 1/5
pnpm installLast reviewed commit: aedf851