Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(docker): 显式构建并校验 Studio (#4305)

Axiomothd933667c7eca
diff --git a/.dockerignore b/.dockerignore
index 3a2c4403a..50d7a2a3b 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -5,8 +5,12 @@
__pycache__
*.py[cod]
.pytest_cache
+.ruff_cache
.coverage
htmlcov
+target/
+src/build/
+docs/.vitepress/dist/
web-studio/node_modules
web-studio/dist
openviking/web_studio/dist
diff --git a/Dockerfile b/Dockerfile
index ef492a857..07500fd9e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,17 +4,24 @@
# ragfs-python's default S3-enabled dependency set currently requires rustc >= 1.91.1.
FROM rust:1.91.1-trixie AS rust-toolchain
-# Stage 2: build Python environment with uv (builds Rust CLI + C++ extension + web-studio from source)
+# Stage 2: build Studio separately so npm failures stop the Docker build.
+FROM node:24-trixie-slim AS web-studio-builder
+ARG TARGETPLATFORM
+WORKDIR /app/web-studio
+
+# Keep npm install cached when only Studio sources change.
+COPY web-studio/package.json web-studio/package-lock.json ./
+RUN --mount=type=cache,target=/root/.npm,id=npm-${TARGETPLATFORM} npm ci
+COPY web-studio/ ./
+RUN npm run build -- --base=/studio/ \
+ && test -f dist/index.html
+
+# Stage 3: build Python environment with uv (builds Rust CLI + C++ extension)
FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim AS py-builder
# Reuse Rust toolchain from stage 1 so setup.py can compile ov CLI in-place.
COPY --from=rust-toolchain /usr/local/cargo /usr/local/cargo
COPY --from=rust-toolchain /usr/local/rustup /usr/local/rustup
-# Provide Node.js so setup.py build_py can build web-studio SPA in-tree.
-COPY --from=node:24-trixie-slim /usr/local/bin/node /usr/local/bin/
-COPY --from=node:24-trixie-slim /usr/local/lib/node_modules/ /usr/local/lib/node_modules/
-RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
- && ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
ENV CARGO_HOME=/usr/local/cargo
ENV RUSTUP_HOME=/usr/local/rustup
ENV PATH="/app/.venv/bin:/usr/local/cargo/bin:${PATH}"
@@ -50,26 +57,21 @@ COPY build_support/ build_support/
COPY bot/ bot/
COPY crates/ crates/
COPY openviking/ openviking/
+COPY --from=web-studio-builder /app/web-studio/dist/ openviking/web_studio/dist/
COPY openviking_cli/ openviking_cli/
COPY src/ src/
COPY third_party/ third_party/
-COPY web-studio/ web-studio/
-# Install project and dependencies (triggers setup.py build_py → web-studio
-# SPA build + build_ext → native extensions).
+# Install project and dependencies. setup.py packages the copied Studio bundle
+# without running npm again, while build_ext still builds native extensions.
# Default to auto-refreshing uv.lock inside the ephemeral build context when it is
# stale, so Docker builds stay unblocked after dependency changes. Set
# UV_LOCK_STRATEGY=locked to keep fail-fast reproducibility checks.
RUN --mount=type=cache,target=/root/.cache/uv,id=uv-${TARGETPLATFORM} \
- --mount=type=cache,target=/root/.npm,id=npm-${TARGETPLATFORM} \
--mount=type=cache,target=/cargo-target,id=cargo-target-${TARGETPLATFORM} \
--mount=type=cache,target=/usr/local/cargo/registry,id=cargo-registry-${TARGETPLATFORM} \
--mount=type=cache,target=/usr/local/cargo/git,id=cargo-git-${TARGETPLATFORM} \
--mount=type=cache,target=/root/.ccache,id=ccache-${TARGETPLATFORM} \
- # The source checkout may contain a previously generated Studio bundle.
- # Remove it so setup.py rebuilds the SPA from the current TypeScript source
- # instead of silently packaging stale browser code into the image.
- rm -rf openviking/web_studio/dist; \
if [ -n "${OPENVIKING_VERSION:-}" ]; then \
export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENVIKING="${OPENVIKING_VERSION}"; \
elif [ -f openviking/_version.py ]; then \
@@ -92,9 +94,10 @@ RUN --mount=type=cache,target=/root/.cache/uv,id=uv-${TARGETPLATFORM} \
echo "Unsupported UV_LOCK_STRATEGY: ${UV_LOCK_STRATEGY}" >&2; \
exit 2 \
;; \
- esac
+ esac && \
+ python -c "from importlib.resources import files; p = files('openviking.web_studio').joinpath('dist/index.html'); assert p.is_file(), f'missing Studio bundle: {p}'"
-# Stage 3: runtime
+# Stage 4: runtime
FROM python:3.13-slim-trixie
RUN apt-get update && apt-get install -y --no-install-recommends \