Skip to content

Commit 082c932

Browse files
committed
fix(docker): export Playwright browser runtime path
1 parent 3050b15 commit 082c932

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎Dockerfile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ RUN --mount=type=cache,id=openclaw-bookworm-apt-cache,target=/var/cache/apt,shar
207207
# Adds ~300MB but eliminates the 60-90s Playwright install on every container start.
208208
# Must run after node_modules COPY so playwright-core is available.
209209
ARG OPENCLAW_INSTALL_BROWSER=""
210+
ENV PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright
210211
RUN --mount=type=cache,id=openclaw-bookworm-apt-cache,target=/var/cache/apt,sharing=locked \
211212
--mount=type=cache,id=openclaw-bookworm-apt-lists,target=/var/lib/apt,sharing=locked \
212213
if [ -n "$OPENCLAW_INSTALL_BROWSER" ]; then \
213214
apt-get update && \
214215
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends xvfb && \
215-
mkdir -p /home/node/.cache/ms-playwright && \
216-
PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright \
216+
mkdir -p "$PLAYWRIGHT_BROWSERS_PATH" && \
217217
node /app/node_modules/playwright-core/cli.js install --with-deps chromium && \
218-
chown -R node:node /home/node/.cache/ms-playwright; \
218+
chown -R node:node "$PLAYWRIGHT_BROWSERS_PATH"; \
219219
fi
220220

221221
# Optionally install Docker CLI for sandbox container management.

‎docs/install/docker.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,9 @@ See [ClawDock](/install/clawdock) for the full helper guide.
414414
docker compose run --rm openclaw-cli \
415415
node /app/node_modules/playwright-core/cli.js install chromium
416416
```
417-
4. **Persist browser downloads**: set
418-
`PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright` and use
419-
`OPENCLAW_HOME_VOLUME` or `OPENCLAW_EXTRA_MOUNTS`. OpenClaw auto-detects
420-
the persisted Chromium on Linux.
417+
4. **Persist browser downloads**: use `OPENCLAW_HOME_VOLUME` or
418+
`OPENCLAW_EXTRA_MOUNTS`. OpenClaw auto-detects the Docker image's
419+
Playwright-managed Chromium on Linux.
421420

422421
</Accordion>
423422

‎extensions/browser/src/browser/chrome.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,21 @@ export async function launchOpenClawChrome(
441441
userDataDir,
442442
...launchOptions,
443443
});
444+
const env = {
445+
...omitChromeProxyEnv(process.env),
446+
// Reduce accidental sharing with the user's env.
447+
HOME: os.homedir(),
448+
};
449+
if (process.platform === "linux") {
450+
env.XDG_CONFIG_HOME ??= path.join(os.tmpdir(), ".chromium");
451+
env.XDG_CACHE_HOME ??= path.join(os.tmpdir(), ".chromium");
452+
}
444453
// stdio tuple: discard stdout to prevent buffer saturation in constrained
445454
// environments (e.g. Docker), while keeping stderr piped for diagnostics.
446455
// Cast to ChildProcessWithoutNullStreams so callers can use .stderr safely;
447456
// the tuple overload resolution varies across @types/node versions.
448457
const preparedSpawn = prepareOomScoreAdjustedSpawn(exe.path, args, {
449-
env: {
450-
...omitChromeProxyEnv(process.env),
451-
// Reduce accidental sharing with the user's env.
452-
HOME: os.homedir(),
453-
},
458+
env,
454459
});
455460
return spawn(preparedSpawn.command, preparedSpawn.args, {
456461
stdio: ["ignore", "ignore", "pipe"],

‎test/scripts/test-install-sh-docker.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ describe("test-install-sh-docker", () => {
7474
expect(dockerfile).toContain("NODE_OPTIONS=--max-old-space-size=8192 pnpm build:docker");
7575
});
7676

77+
it("exports the Playwright browser cache installed by the root Dockerfile", () => {
78+
const dockerfile = readFileSync("Dockerfile", "utf8");
79+
80+
expect(dockerfile).toContain("ENV PLAYWRIGHT_BROWSERS_PATH=/home/node/.cache/ms-playwright");
81+
expect(dockerfile).toContain('mkdir -p "$PLAYWRIGHT_BROWSERS_PATH"');
82+
expect(dockerfile).toContain(
83+
"node /app/node_modules/playwright-core/cli.js install --with-deps chromium",
84+
);
85+
});
86+
7787
it("allows repository branch history and release tags for secret-backed Docker release checks", () => {
7888
const workflow = readFileSync(LIVE_E2E_WORKFLOW_PATH, "utf8");
7989

0 commit comments

Comments
 (0)