mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 04:40:43 +00:00
fix(docker): normalize plugin build args
This commit is contained in:
@@ -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 && \
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user