Skip to content

Commit 47b8e56

Browse files
authored
feat(docker): add image apt package build arg
feat(docker): add image apt package build arg Add OPENCLAW_IMAGE_APT_PACKAGES as the preferred runtime-neutral image build arg for Docker and Podman apt package installs while keeping OPENCLAW_DOCKER_APT_PACKAGES as the legacy fallback. Maintainer verification: - pnpm docs:list - node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/docker-setup.e2e.test.ts - node scripts/run-vitest.mjs src/dockerfile.test.ts test/scripts/test-install-sh-docker.test.ts - node scripts/run-vitest.mjs run --config test/vitest/vitest.cron.config.ts src/cron/isolated-agent.model-overrides.test.ts - pnpm exec oxfmt --check --threads=1 docs/install/docker.md docs/install/podman.md scripts/clawdock/README.md docs/help/faq.md CHANGELOG.md - git diff --check origin/main...HEAD - .agents/skills/autoreview/scripts/autoreview --mode local - .agents/skills/autoreview/scripts/autoreview --mode branch - pnpm check:changed via Blacksmith Testbox tbx_01krwqmfhcdekaczvrkxnb7t59, Actions run 26014630478, exit 0 Known CI note: checks-node-core-runtime-shared timed out repeatedly in unrelated src/cron/isolated-agent.model-overrides.test.ts on GitHub Actions; the same test passes locally after this rebase. Co-authored-by: Said Urtabajev <[email protected]>
1 parent 57bc268 commit 47b8e56

9 files changed

Lines changed: 110 additions & 34 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Docs: https://docs.openclaw.ai
77
### Changes
88

99
- Dependencies: update Pi packages to 0.75.1 and raise the minimum supported Node.js 22 line to 22.19.
10+
- Docker/Podman: add `OPENCLAW_IMAGE_APT_PACKAGES` as the runtime-neutral image build arg for extra apt packages while keeping `OPENCLAW_DOCKER_APT_PACKAGES` as a legacy fallback. (#62431) Thanks @urtabajev.
1011
- Mac app: redesign Settings pages with consistent card layouts, cached navigation, cleaner permissions/voice/skills/cron/exec/debug panes, and steadier spacing around the native sidebar.
1112
- Skills: rename the repo-local Codex closeout review skill and helper to `autoreview` while preserving the Codex-first fallback behavior.
1213
- Skills: add a meme-maker skill for curated template search, local SVG/PNG rendering, Imgflip hosted rendering, and Know Your Meme provenance links.

‎Dockerfile‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,16 @@ RUN install -d -m 0755 "$COREPACK_HOME" && \
198198
chmod -R a+rX "$COREPACK_HOME"
199199

200200
# Install additional system packages needed by your skills or extensions.
201-
# Example: docker build --build-arg OPENCLAW_DOCKER_APT_PACKAGES="python3 wget" .
201+
# Example: docker build --build-arg OPENCLAW_IMAGE_APT_PACKAGES="python3 wget" .
202+
# Legacy alias: OPENCLAW_DOCKER_APT_PACKAGES is still accepted as a fallback.
203+
ARG OPENCLAW_IMAGE_APT_PACKAGES
202204
ARG OPENCLAW_DOCKER_APT_PACKAGES=""
203205
RUN --mount=type=cache,id=openclaw-bookworm-apt-cache,target=/var/cache/apt,sharing=locked \
204206
--mount=type=cache,id=openclaw-bookworm-apt-lists,target=/var/lib/apt,sharing=locked \
205-
if [ -n "$OPENCLAW_DOCKER_APT_PACKAGES" ]; then \
207+
packages="${OPENCLAW_IMAGE_APT_PACKAGES-$OPENCLAW_DOCKER_APT_PACKAGES}"; \
208+
if [ -n "$packages" ]; then \
206209
apt-get update && \
207-
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $OPENCLAW_DOCKER_APT_PACKAGES; \
210+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $packages; \
208211
fi
209212

210213
# Optionally install Chromium and Xvfb for browser automation.

‎docs/help/faq.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ lives on the [First-run FAQ](/help/faq-first-run).
451451
include system packages, Homebrew, or bundled browsers. For a fuller setup:
452452

453453
- Persist `/home/node` with `OPENCLAW_HOME_VOLUME` so caches survive.
454-
- Bake system deps into the image with `OPENCLAW_DOCKER_APT_PACKAGES`.
454+
- Bake system deps into the image with `OPENCLAW_IMAGE_APT_PACKAGES`.
455455
- Install Playwright browsers via the bundled CLI:
456456
`node /app/node_modules/playwright-core/cli.js install chromium`
457457
- Set `PLAYWRIGHT_BROWSERS_PATH` and ensure the path is persisted.

‎docs/install/docker.md‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,31 @@ and setup-time config writes through `openclaw-gateway` with
123123

124124
The setup script accepts these optional environment variables:
125125

126-
| Variable | Purpose |
127-
| ------------------------------------------ | --------------------------------------------------------------- |
128-
| `OPENCLAW_IMAGE` | Use a remote image instead of building locally |
129-
| `OPENCLAW_DOCKER_APT_PACKAGES` | Install extra apt packages during build (space-separated) |
130-
| `OPENCLAW_EXTENSIONS` | Include selected bundled plugin helpers at build time |
131-
| `OPENCLAW_EXTRA_MOUNTS` | Extra host bind mounts (comma-separated `source:target[:opts]`) |
132-
| `OPENCLAW_HOME_VOLUME` | Persist `/home/node` in a named Docker volume |
133-
| `OPENCLAW_SANDBOX` | Opt in to sandbox bootstrap (`1`, `true`, `yes`, `on`) |
134-
| `OPENCLAW_SKIP_ONBOARDING` | Skip the interactive onboarding step (`1`, `true`, `yes`, `on`) |
135-
| `OPENCLAW_DOCKER_SOCKET` | Override Docker socket path |
136-
| `OPENCLAW_DISABLE_BONJOUR` | Disable Bonjour/mDNS advertising (defaults to `1` for Docker) |
137-
| `OPENCLAW_DISABLE_BUNDLED_SOURCE_OVERLAYS` | Disable bundled plugin source bind-mount overlays |
138-
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Shared OTLP/HTTP collector endpoint for OpenTelemetry export |
139-
| `OTEL_EXPORTER_OTLP_*_ENDPOINT` | Signal-specific OTLP endpoints for traces, metrics, or logs |
140-
| `OTEL_EXPORTER_OTLP_PROTOCOL` | OTLP protocol override. Only `http/protobuf` is supported today |
141-
| `OTEL_SERVICE_NAME` | Service name used for OpenTelemetry resources |
142-
| `OTEL_SEMCONV_STABILITY_OPT_IN` | Opt in to latest experimental GenAI semantic attributes |
143-
| `OPENCLAW_OTEL_PRELOADED` | Skip starting a second OpenTelemetry SDK when one is preloaded |
126+
| Variable | Purpose |
127+
| ------------------------------------------ | --------------------------------------------------------------------- |
128+
| `OPENCLAW_IMAGE` | Use a remote image instead of building locally |
129+
| `OPENCLAW_IMAGE_APT_PACKAGES` | Install extra apt packages during build (space-separated) |
130+
| `OPENCLAW_EXTENSIONS` | Pre-install plugin dependencies at build time (space-separated names) |
131+
| `OPENCLAW_EXTRA_MOUNTS` | Extra host bind mounts (comma-separated `source:target[:opts]`) |
132+
| `OPENCLAW_HOME_VOLUME` | Persist `/home/node` in a named Docker volume |
133+
| `OPENCLAW_SANDBOX` | Opt in to sandbox bootstrap (`1`, `true`, `yes`, `on`) |
134+
| `OPENCLAW_SKIP_ONBOARDING` | Skip the interactive onboarding step (`1`, `true`, `yes`, `on`) |
135+
| `OPENCLAW_DOCKER_SOCKET` | Override Docker socket path |
136+
| `OPENCLAW_DISABLE_BONJOUR` | Disable Bonjour/mDNS advertising (defaults to `1` for Docker) |
137+
| `OPENCLAW_DISABLE_BUNDLED_SOURCE_OVERLAYS` | Disable bundled plugin source bind-mount overlays |
138+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Shared OTLP/HTTP collector endpoint for OpenTelemetry export |
139+
| `OTEL_EXPORTER_OTLP_*_ENDPOINT` | Signal-specific OTLP endpoints for traces, metrics, or logs |
140+
| `OTEL_EXPORTER_OTLP_PROTOCOL` | OTLP protocol override. Only `http/protobuf` is supported today |
141+
| `OTEL_SERVICE_NAME` | Service name used for OpenTelemetry resources |
142+
| `OTEL_SEMCONV_STABILITY_OPT_IN` | Opt in to latest experimental GenAI semantic attributes |
143+
| `OPENCLAW_OTEL_PRELOADED` | Skip starting a second OpenTelemetry SDK when one is preloaded |
144144

145145
The official Docker image does not ship Homebrew. During onboarding, OpenClaw
146146
hides brew-only skill dependency installers when it is running in a Linux
147147
container without `brew`; those dependencies must be provided by a custom image
148148
or installed manually. For dependencies available from Debian packages, use
149-
`OPENCLAW_DOCKER_APT_PACKAGES` during image build.
149+
`OPENCLAW_IMAGE_APT_PACKAGES` during image build. The legacy
150+
`OPENCLAW_DOCKER_APT_PACKAGES` name is still accepted.
150151

151152
Maintainers can test bundled plugin source against a packaged image by mounting
152153
one plugin source directory over its packaged source path, for example
@@ -421,7 +422,7 @@ See [ClawDock](/install/clawdock) for the full helper guide.
421422
full-featured container:
422423

423424
1. **Persist `/home/node`**: `export OPENCLAW_HOME_VOLUME="openclaw_home"`
424-
2. **Bake system deps**: `export OPENCLAW_DOCKER_APT_PACKAGES="git curl jq"`
425+
2. **Bake system deps**: `export OPENCLAW_IMAGE_APT_PACKAGES="git curl jq"`
425426
3. **Bake Playwright Chromium**: `export OPENCLAW_INSTALL_BROWSER=1`
426427
4. **Or install Playwright browsers into a persisted volume**:
427428
```bash

‎docs/install/podman.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ You can also set `OPENCLAW_PODMAN_QUADLET=1`.
6161
Optional build/setup env vars:
6262

6363
- `OPENCLAW_IMAGE` or `OPENCLAW_PODMAN_IMAGE` -- use an existing/pulled image instead of building `openclaw:local`
64-
- `OPENCLAW_DOCKER_APT_PACKAGES` -- install extra apt packages during image build
64+
- `OPENCLAW_IMAGE_APT_PACKAGES` -- install extra apt packages during image build (also accepts legacy `OPENCLAW_DOCKER_APT_PACKAGES`)
6565
- `OPENCLAW_EXTENSIONS` -- pre-install plugin dependencies at build time
6666
- `OPENCLAW_INSTALL_BROWSER` -- pre-install Chromium and Xvfb for browser automation (set to `1` to enable)
6767

‎scripts/clawdock/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ See `.env.example` for all supported keys.
182182

183183
The `Dockerfile` supports two optional build args:
184184

185-
- `OPENCLAW_DOCKER_APT_PACKAGES` — extra apt packages to install (e.g. `ffmpeg`)
185+
- `OPENCLAW_IMAGE_APT_PACKAGES` — extra apt packages to install (e.g. `ffmpeg`); also accepts legacy `OPENCLAW_DOCKER_APT_PACKAGES`
186186
- `OPENCLAW_INSTALL_BROWSER=1` — pre-install Chromium for browser automation (adds ~300MB, but skips the 60-90s Playwright install on each container start)
187187

188188
### How It Works in Docker

‎scripts/docker/setup.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export OPENCLAW_BRIDGE_PORT="${OPENCLAW_BRIDGE_PORT:-18790}"
296296
export OPENCLAW_GATEWAY_BIND="${OPENCLAW_GATEWAY_BIND:-lan}"
297297
export OPENCLAW_DISABLE_BONJOUR="${OPENCLAW_DISABLE_BONJOUR:-}"
298298
export OPENCLAW_IMAGE="$IMAGE_NAME"
299-
export OPENCLAW_DOCKER_APT_PACKAGES="${OPENCLAW_DOCKER_APT_PACKAGES:-}"
299+
export OPENCLAW_IMAGE_APT_PACKAGES="${OPENCLAW_IMAGE_APT_PACKAGES-${OPENCLAW_DOCKER_APT_PACKAGES:-}}"
300300
export OPENCLAW_EXTENSIONS="${OPENCLAW_EXTENSIONS:-}"
301301
export OPENCLAW_INSTALL_BROWSER="${OPENCLAW_INSTALL_BROWSER:-}"
302302
export OPENCLAW_EXTRA_MOUNTS="$EXTRA_MOUNTS"
@@ -500,7 +500,7 @@ upsert_env "$ENV_FILE" \
500500
OPENCLAW_IMAGE \
501501
OPENCLAW_EXTRA_MOUNTS \
502502
OPENCLAW_HOME_VOLUME \
503-
OPENCLAW_DOCKER_APT_PACKAGES \
503+
OPENCLAW_IMAGE_APT_PACKAGES \
504504
OPENCLAW_EXTENSIONS \
505505
OPENCLAW_INSTALL_BROWSER \
506506
OPENCLAW_SANDBOX \
@@ -522,7 +522,7 @@ upsert_env "$ENV_FILE" \
522522
if [[ "$IMAGE_NAME" == "openclaw:local" ]]; then
523523
echo "==> Building Docker image: $IMAGE_NAME"
524524
run_docker_build \
525-
--build-arg "OPENCLAW_DOCKER_APT_PACKAGES=${OPENCLAW_DOCKER_APT_PACKAGES}" \
525+
--build-arg "OPENCLAW_IMAGE_APT_PACKAGES=${OPENCLAW_IMAGE_APT_PACKAGES}" \
526526
--build-arg "OPENCLAW_EXTENSIONS=${OPENCLAW_EXTENSIONS}" \
527527
--build-arg "OPENCLAW_INSTALL_BROWSER=${OPENCLAW_INSTALL_BROWSER}" \
528528
--build-arg "OPENCLAW_INSTALL_DOCKER_CLI=${OPENCLAW_INSTALL_DOCKER_CLI:-}" \

‎scripts/podman/setup.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,10 @@ install -d -m 700 "$OPENCLAW_CONFIG_DIR" "$OPENCLAW_WORKSPACE_DIR"
358358
ensure_private_existing_dir_owned_by_user "config directory" "$OPENCLAW_CONFIG_DIR"
359359
ensure_private_existing_dir_owned_by_user "workspace directory" "$OPENCLAW_WORKSPACE_DIR"
360360

361+
OPENCLAW_IMAGE_APT_PACKAGES="${OPENCLAW_IMAGE_APT_PACKAGES-${OPENCLAW_DOCKER_APT_PACKAGES:-}}"
361362
BUILD_ARGS=()
362-
if [[ -n "${OPENCLAW_DOCKER_APT_PACKAGES:-}" ]]; then
363-
BUILD_ARGS+=(--build-arg "OPENCLAW_DOCKER_APT_PACKAGES=${OPENCLAW_DOCKER_APT_PACKAGES}")
363+
if [[ -n "$OPENCLAW_IMAGE_APT_PACKAGES" ]]; then
364+
BUILD_ARGS+=(--build-arg "OPENCLAW_IMAGE_APT_PACKAGES=${OPENCLAW_IMAGE_APT_PACKAGES}")
364365
fi
365366
if [[ -n "${OPENCLAW_EXTENSIONS:-}" ]]; then
366367
BUILD_ARGS+=(--build-arg "OPENCLAW_EXTENSIONS=${OPENCLAW_EXTENSIONS}")

‎src/docker-setup.e2e.test.ts‎

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ describe("scripts/docker/setup.sh", () => {
258258
const activeSandbox = requireSandbox(sandbox);
259259

260260
const result = runDockerSetup(activeSandbox, {
261-
OPENCLAW_DOCKER_APT_PACKAGES: "ffmpeg build-essential",
261+
OPENCLAW_DOCKER_APT_PACKAGES: "curl wget",
262262
OPENCLAW_EXTRA_MOUNTS: undefined,
263263
OPENCLAW_HOME_VOLUME: "openclaw-home",
264264
});
265265
expect(result.status).toBe(0);
266266
const envFile = await readFile(join(activeSandbox.rootDir, ".env"), "utf8");
267-
expect(envFile).toContain("OPENCLAW_DOCKER_APT_PACKAGES=ffmpeg build-essential");
267+
expect(envFile).toContain("OPENCLAW_IMAGE_APT_PACKAGES=curl wget");
268268
expect(envFile).toContain("OPENCLAW_EXTRA_MOUNTS=");
269269
expect(envFile).toContain("OPENCLAW_HOME_VOLUME=openclaw-home"); // pragma: allowlist secret
270270
expect(envFile).toContain("OPENCLAW_DISABLE_BONJOUR=");
@@ -282,7 +282,7 @@ describe("scripts/docker/setup.sh", () => {
282282
expect(extraCompose).toContain("volumes:");
283283
expect(extraCompose).toContain("openclaw-home:");
284284
const log = await readDockerLog(activeSandbox);
285-
expect(log).toContain("--build-arg OPENCLAW_DOCKER_APT_PACKAGES=ffmpeg build-essential");
285+
expect(log).toContain("--build-arg OPENCLAW_IMAGE_APT_PACKAGES=curl wget");
286286
expect(log).toContain(
287287
`run --rm --no-deps ${prestartContainerEnvFlags} --entrypoint node openclaw-gateway dist/index.js onboard --mode local --no-install-daemon`,
288288
);
@@ -304,6 +304,61 @@ describe("scripts/docker/setup.sh", () => {
304304
expect(envFile).toContain("OPENCLAW_DISABLE_BONJOUR=0");
305305
});
306306

307+
it("normalizes legacy OPENCLAW_DOCKER_APT_PACKAGES into OPENCLAW_IMAGE_APT_PACKAGES", async () => {
308+
const activeSandbox = requireSandbox(sandbox);
309+
await resetDockerLog(activeSandbox);
310+
311+
const result = runDockerSetup(activeSandbox, {
312+
OPENCLAW_DOCKER_APT_PACKAGES: "curl wget",
313+
});
314+
expect(result.status).toBe(0);
315+
316+
const envFile = await readFile(join(activeSandbox.rootDir, ".env"), "utf8");
317+
expect(envFile).toContain("OPENCLAW_IMAGE_APT_PACKAGES=curl wget");
318+
expect(envFile).not.toContain("OPENCLAW_DOCKER_APT_PACKAGES");
319+
320+
const log = await readDockerLog(activeSandbox);
321+
expect(log).toContain("--build-arg OPENCLAW_IMAGE_APT_PACKAGES=curl wget");
322+
expect(log).not.toContain("--build-arg OPENCLAW_DOCKER_APT_PACKAGES");
323+
});
324+
325+
it("prefers OPENCLAW_IMAGE_APT_PACKAGES over legacy OPENCLAW_DOCKER_APT_PACKAGES", async () => {
326+
const activeSandbox = requireSandbox(sandbox);
327+
await resetDockerLog(activeSandbox);
328+
329+
const result = runDockerSetup(activeSandbox, {
330+
OPENCLAW_IMAGE_APT_PACKAGES: "curl wget httpie",
331+
OPENCLAW_DOCKER_APT_PACKAGES: "curl wget",
332+
});
333+
expect(result.status).toBe(0);
334+
335+
const envFile = await readFile(join(activeSandbox.rootDir, ".env"), "utf8");
336+
expect(envFile).toContain("OPENCLAW_IMAGE_APT_PACKAGES=curl wget httpie");
337+
expect(envFile).not.toContain("OPENCLAW_DOCKER_APT_PACKAGES");
338+
339+
const log = await readDockerLog(activeSandbox);
340+
expect(log).toContain("--build-arg OPENCLAW_IMAGE_APT_PACKAGES=curl wget httpie");
341+
expect(log).not.toMatch(/--build-arg OPENCLAW_IMAGE_APT_PACKAGES=curl wget(?! httpie)/);
342+
});
343+
344+
it("explicitly empty OPENCLAW_IMAGE_APT_PACKAGES suppresses legacy fallback", async () => {
345+
const activeSandbox = requireSandbox(sandbox);
346+
await resetDockerLog(activeSandbox);
347+
348+
const result = runDockerSetup(activeSandbox, {
349+
OPENCLAW_IMAGE_APT_PACKAGES: "",
350+
OPENCLAW_DOCKER_APT_PACKAGES: "curl wget",
351+
});
352+
expect(result.status).toBe(0);
353+
354+
const envFile = await readFile(join(activeSandbox.rootDir, ".env"), "utf8");
355+
expect(envFile).toContain("OPENCLAW_IMAGE_APT_PACKAGES=");
356+
expect(envFile).not.toContain("curl wget");
357+
358+
const log = await readDockerLog(activeSandbox);
359+
expect(log).not.toContain("--build-arg OPENCLAW_IMAGE_APT_PACKAGES=curl wget");
360+
});
361+
307362
it("avoids shared-network openclaw-cli before the gateway is started", async () => {
308363
const activeSandbox = requireSandbox(sandbox);
309364

@@ -742,4 +797,19 @@ describe("scripts/docker/setup.sh", () => {
742797
compose.match(/OPENCLAW_WORKSPACE_DIR: \/home\/node\/\.openclaw\/workspace$/gm),
743798
).toHaveLength(2);
744799
});
800+
801+
it("Dockerfile ARG OPENCLAW_IMAGE_APT_PACKAGES must not have a default value", async () => {
802+
// If the ARG has a default (e.g. ARG OPENCLAW_IMAGE_APT_PACKAGES=""), Docker treats it as
803+
// "set" even when no --build-arg is passed. That breaks the RUN fallback expression
804+
// ${OPENCLAW_IMAGE_APT_PACKAGES-$OPENCLAW_DOCKER_APT_PACKAGES} because the variable is
805+
// never truly unset, so legacy-only callers using --build-arg OPENCLAW_DOCKER_APT_PACKAGES
806+
// get nothing installed — a backward-compat regression.
807+
const dockerfile = await readFile(join(repoRoot, "Dockerfile"), "utf8");
808+
const argLine = dockerfile
809+
.split("\n")
810+
.find((line) => line.startsWith("ARG OPENCLAW_IMAGE_APT_PACKAGES"));
811+
expect(argLine).toBeDefined();
812+
// Must be bare `ARG OPENCLAW_IMAGE_APT_PACKAGES` with no default assignment
813+
expect(argLine).toBe("ARG OPENCLAW_IMAGE_APT_PACKAGES");
814+
});
745815
});

0 commit comments

Comments
 (0)