Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Fix critical vulnerabilities - Drop node_modules from store stage (#929)

Chirag Jainedbcba42aa16
diff --git a/.changeset/docker-prod-deps-prune-fetch.md b/.changeset/docker-prod-deps-prune-fetch.md
new file mode 100644
index 000000000..77dd08a2c
--- /dev/null
+++ b/.changeset/docker-prod-deps-prune-fetch.md
@@ -0,0 +1,5 @@
+---
+'@truefoundry/trueforge': patch
+---
+
+Stop `pnpm fetch` from leaving a full `node_modules/.pnpm` in the image store stage so the production install no longer copies build tooling (esbuild, TypeScript, etc.) into the runtime image.
diff --git a/Dockerfile b/Dockerfile
index f364555db..10f7ae2d6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,6 +10,9 @@
# See https://pnpm.io/cli/fetch. BuildKit cache mounts are avoided so the same
# file builds on Railway Metal (which requires a hardcoded service id in mount ids).
#
+# `pnpm fetch` also writes a full node_modules/.pnpm; remove it so --prod install
+# does not inherit build tooling into the runtime image.
+#
# Base images are build args so a local or contributor build stays on the public
# Docker Hub image. The release workflow overrides both with the hardened node
# images from the TrueFoundry private registry (builder: node:24-dev, runtime:
@@ -36,7 +39,8 @@ WORKDIR /app
# ---------------------------------------------------------------------------
FROM base AS store
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
-RUN pnpm fetch
+# Populate /pnpm/store only; drop the full virtual store fetch also writes.
+RUN pnpm fetch && rm -rf node_modules
# ---------------------------------------------------------------------------
# workspace: install inputs shared by every stage below - the manifests plus the