From a07d8cbf8a233853cc55d250ad720157ff9d3e1a Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 4 May 2026 15:16:04 -0700 Subject: [PATCH] fix(docker): normalize plugin build args --- Dockerfile | 8 ++++---- src/dockerfile.test.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d14c730132e..081e0cfbb1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1.7 -# Opt-in extension dependencies at build time (space-separated directory names). -# Example: docker build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel matrix" . +# Opt-in plugin dependencies at build time (space- or comma-separated directory names). +# Example: docker build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel,matrix" . # # Multi-stage build produces a minimal runtime image without build tools, # source code, or Bun. Works with Docker, Buildx, and Podman. @@ -32,7 +32,7 @@ ARG OPENCLAW_BUNDLED_PLUGIN_DIR # Copy package.json for opted-in extensions so pnpm resolves their deps. RUN --mount=type=bind,source=${OPENCLAW_BUNDLED_PLUGIN_DIR},target=/tmp/${OPENCLAW_BUNDLED_PLUGIN_DIR},readonly \ mkdir -p /out && \ - for ext in $OPENCLAW_EXTENSIONS; do \ + for ext in $(printf '%s\n' "$OPENCLAW_EXTENSIONS" | tr ',' ' '); do \ if [ -f "/tmp/${OPENCLAW_BUNDLED_PLUGIN_DIR}/$ext/package.json" ]; then \ mkdir -p "/out/$ext" && \ cp "/tmp/${OPENCLAW_BUNDLED_PLUGIN_DIR}/$ext/package.json" "/out/$ext/package.json"; \ @@ -118,7 +118,7 @@ ARG OPENCLAW_BUNDLED_PLUGIN_DIR # prune must not rediscover unrelated workspaces from the later full source # copy. RUN printf 'packages:\n - .\n - ui\n' > /tmp/pnpm-workspace.runtime.yaml && \ - for ext in $OPENCLAW_EXTENSIONS; do \ + for ext in $(printf '%s\n' "$OPENCLAW_EXTENSIONS" | tr ',' ' '); do \ printf ' - %s/%s\n' "$OPENCLAW_BUNDLED_PLUGIN_DIR" "$ext" >> /tmp/pnpm-workspace.runtime.yaml; \ done && \ cp /tmp/pnpm-workspace.runtime.yaml pnpm-workspace.yaml && \ diff --git a/src/dockerfile.test.ts b/src/dockerfile.test.ts index b795f19f9a0..ef7e2d35f88 100644 --- a/src/dockerfile.test.ts +++ b/src/dockerfile.test.ts @@ -105,9 +105,18 @@ describe("Dockerfile", () => { it("prunes runtime dependencies after the build stage", async () => { const dockerfile = await readFile(dockerfilePath, "utf8"); + const normalizedExtensionLoop = + "for ext in $(printf '%s\\n' \"$OPENCLAW_EXTENSIONS\" | tr ',' ' '); do \\"; expect(dockerfile).toContain("FROM build AS runtime-assets"); expect(dockerfile).toContain("ARG OPENCLAW_EXTENSIONS"); expect(dockerfile).toContain("ARG OPENCLAW_BUNDLED_PLUGIN_DIR"); + expect(dockerfile).toContain( + "Opt-in plugin dependencies at build time (space- or comma-separated directory names).", + ); + expect(dockerfile).toContain( + 'Example: docker build --build-arg OPENCLAW_EXTENSIONS="diagnostics-otel,matrix" .', + ); + expect(dockerfile.split(normalizedExtensionLoop).length - 1).toBe(2); expect(dockerfile).toContain("pnpm-workspace.runtime.yaml"); expect(dockerfile).toContain(" - ui\\n"); expect(dockerfile).toContain("CI=true NPM_CONFIG_FROZEN_LOCKFILE=false pnpm prune --prod");