Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(docker): bundle pinned native modules at image build time

Steven Enamakel526aa6674898
diff --git a/Dockerfile b/Dockerfile
index 01c9c6dce3..1e6f55bc4a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -88,7 +88,23 @@ RUN touch crates/openhuman-cli/src/main.rs crates/openhuman-core/src/lib.rs \
cp "target/${CARGO_PROFILE}/openhuman-core" /tmp/openhuman-core
# ==========================================================================
-# Stage 2: Minimal runtime image
+# Stage 2: Stage the registry-pinned native modules at build time
+# ==========================================================================
+# Downloads and digest-verifies every module archive the compiled registry
+# pins for this image's architecture (buildx runs this stage per platform), so
+# the container never needs GitHub access to load a module. The oldest
+# published Linux build (ubuntu-22.04, glibc 2.35) runs on bookworm (2.36).
+FROM node:24-bookworm-slim AS modules
+WORKDIR /repo
+COPY scripts/lib/module-pins.mjs scripts/lib/module-pins.mjs
+COPY scripts/ci/self-hosted/test-module-assets.mjs scripts/ci/self-hosted/test-module-assets.mjs
+COPY scripts/release/stage-modules.mjs scripts/release/stage-modules.mjs
+COPY crates/openhuman-core/src/modules/registry.rs crates/openhuman-core/src/modules/registry.rs
+COPY crates/openhuman-core/src/modules/registry/ crates/openhuman-core/src/modules/registry/
+RUN node scripts/release/stage-modules.mjs --output /bundled-modules
+
+# ==========================================================================
+# Stage 3: Minimal runtime image
# ==========================================================================
FROM debian:bookworm-slim AS runtime
@@ -121,6 +137,11 @@ RUN mkdir -p /home/openhuman/.openhuman \
# Copy the built binary
COPY --from=builder /tmp/openhuman-core /usr/local/bin/openhuman-core
+# Pinned native modules, verified at image build time. The core still checks
+# each archive against the compiled digest and tinybus admission before loading.
+COPY --from=modules /bundled-modules /opt/openhuman/bundled-modules
+ENV OPENHUMAN_BUNDLED_MODULES=/opt/openhuman/bundled-modules
+
# Copy the entrypoint script that chowns the workspace volume before dropping
# privileges. The script is a separate file so the E2E entrypoint
# (e2e/docker-entrypoint.sh) is not affected.
diff --git a/bench/harnesses/bundles/Dockerfile.openhuman b/bench/harnesses/bundles/Dockerfile.openhuman
index 5ea5ab6d94..721d4dac8f 100644
--- a/bench/harnesses/bundles/Dockerfile.openhuman
+++ b/bench/harnesses/bundles/Dockerfile.openhuman
@@ -20,6 +20,16 @@ RUN --mount=type=cache,target=/root/.cargo/registry \
cargo build --profile "${CARGO_PROFILE}" -p openhuman-cli --bin openhuman-core \
&& install -D "target/$([ "${CARGO_PROFILE}" = release ] && echo release || echo "${CARGO_PROFILE}")/openhuman-core" /out/openhuman/openhuman-core
+# Pinned native modules, staged at build time so benches never fetch them.
+FROM node:24-bookworm-slim AS modules
+WORKDIR /repo
+COPY scripts/lib/module-pins.mjs scripts/lib/module-pins.mjs
+COPY scripts/ci/self-hosted/test-module-assets.mjs scripts/ci/self-hosted/test-module-assets.mjs
+COPY scripts/release/stage-modules.mjs scripts/release/stage-modules.mjs
+COPY crates/openhuman-core/src/modules/registry.rs crates/openhuman-core/src/modules/registry.rs
+COPY crates/openhuman-core/src/modules/registry/ crates/openhuman-core/src/modules/registry/
+RUN node scripts/release/stage-modules.mjs --output /bundled-modules
+
FROM ubuntu:22.04 AS bundle
ARG GIT_SHA=unknown
ARG ADAPTER=adapters/openhuman.sh
@@ -32,6 +42,9 @@ RUN set -eux; mkdir -p /opt/harness/node; \
file="$(curl -fsSL "$base/SHASUMS256.txt" | awk -v a="linux-$arch.tar.xz" '$2 ~ a {print $2}')"; \
curl -fsSL "$base/$file" | tar -xJ --strip-components=1 -C /opt/harness/node
COPY --from=builder /out/openhuman /opt/harness/openhuman
+# The core finds `bundled-modules/` beside its binary (OPENHUMAN_BUNDLED_MODULES
+# overrides), so the extracted bundle stays relocatable.
+COPY --from=modules /bundled-modules /opt/harness/openhuman/bundled-modules
COPY bench/harnesses/bundles/adapters/_common.sh /opt/harness/_common.sh
COPY bench/harnesses/bundles/${ADAPTER} /opt/harness/adapter.sh
COPY bench/harnesses/bundles/forward.mjs /opt/harness/forward.mjs