Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(cicd): re-add nextauth etc to docker (#12865)

Nimar8cc4a5537f18
diff --git a/web/Dockerfile b/web/Dockerfile
index 5885f01d15..88ec9c7890 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -17,7 +17,7 @@ FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine AS runtime-base
# Remove build-only package managers. npm stays here because the runner stage
# uses it to install prisma and optional dd-trace before removing it.
RUN rm -rf /usr/local/lib/node_modules/corepack && \
- rm -f /usr/local/bin/corepack /usr/local/bin/pnpm /usr/local/bin/pnpx /usr/local/bin/yarn /usr/local/bin/yarnpkg
+ rm -f /usr/local/bin/corepack /usr/local/bin/yarn /usr/local/bin/yarnpkg
FROM --platform=${TARGETPLATFORM:-linux/amd64} build-base AS pruner
@@ -122,7 +122,7 @@ ARG GID=1001
RUN addgroup --system --gid ${GID} nodejs
RUN adduser --system --uid ${UID} nextjs
-RUN npm install -g --no-package-lock --no-save [email protected]
+RUN npm install -g --no-package-lock --no-save [email protected]
# Install dd-trace only if NEXT_PUBLIC_LANGFUSE_CLOUD_REGION is configured
ARG NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
@@ -130,7 +130,7 @@ RUN if [ -n "$NEXT_PUBLIC_LANGFUSE_CLOUD_REGION" ]; then \
npm install --no-package-lock --no-save [email protected]; \
fi
-# Runtime images do not need npm once explicit runtime tools are installed.
+# npm is only used for the installs above; remove it from the final runtime image.
RUN rm -rf /usr/local/lib/node_modules/npm && \
rm -f /usr/local/bin/npm /usr/local/bin/npx
diff --git a/worker/Dockerfile b/worker/Dockerfile
index 3fbf0604d0..867d57fa7e 100644
--- a/worker/Dockerfile
+++ b/worker/Dockerfile
@@ -14,9 +14,9 @@ RUN corepack enable
RUN corepack prepare [email protected] --activate
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine AS runtime-base
-# Remove package managers from the runtime image; only build stages need them.
+# package managers and build-only CLIs only increase exposure to CVEs -> remove them
RUN rm -rf /usr/local/lib/node_modules/corepack /usr/local/lib/node_modules/npm && \
- rm -f /usr/local/bin/corepack /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/pnpm /usr/local/bin/pnpx /usr/local/bin/yarn /usr/local/bin/yarnpkg
+ rm -f /usr/local/bin/corepack /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/yarn /usr/local/bin/yarnpkg
FROM --platform=${TARGETPLATFORM:-linux/amd64} build-base AS pruner
@@ -50,20 +50,19 @@ RUN turbo run build --filter=worker...
FROM --platform=${TARGETPLATFORM:-linux/amd64} builder AS prod-deps
-RUN rm -rf /prod && \
- pnpm --filter worker deploy --legacy --prod /prod/worker && \
+# previously we copied the --from=builder /app . (includes full node_modules etc)
+# we only need the prod + generated prisma client plus .prisma artifacts
+# @langfuse/shared still pulls in next-auth transitively, so keep the deploy output
+# intact here instead of pruning node_modules in Docker.
+# also, pnpm v10 needs the pnpm legacy deploy implementation, we didn't upgrade that yet
+RUN pnpm --filter worker deploy --legacy --prod /prod/worker && \
builder_prisma_client_dir="$(find /app/node_modules/.pnpm -path '*/node_modules/@prisma/client' -type d | head -n 1)" && \
deployed_prisma_client_dir="$(find /prod/worker/node_modules/.pnpm -path '*/node_modules/@prisma/client' -type d | head -n 1)" && \
builder_prisma_runtime_dir="$(dirname "$(dirname "$builder_prisma_client_dir")")/.prisma" && \
deployed_prisma_runtime_dir="$(dirname "$(dirname "$deployed_prisma_client_dir")")/.prisma" && \
rm -rf "$deployed_prisma_client_dir" "$deployed_prisma_runtime_dir" && \
- mkdir -p "$(dirname "$deployed_prisma_client_dir")" && \
cp -R "$builder_prisma_client_dir" "$deployed_prisma_client_dir" && \
- cp -R "$builder_prisma_runtime_dir" "$deployed_prisma_runtime_dir" && \
- # @langfuse/shared currently brings auth-only Next.js packages that the worker never executes.
- find /prod/worker/node_modules \
- \( -path '*/node_modules/next' -o -path '*/node_modules/next-auth' -o -path '*/.bin/next' \) \
- -exec rm -rf {} +
+ cp -R "$builder_prisma_runtime_dir" "$deployed_prisma_runtime_dir"
FROM --platform=${TARGETPLATFORM:-linux/amd64} runtime-base AS runner
@@ -86,6 +85,7 @@ ARG GID=1001
RUN addgroup --system --gid ${GID} expressjs
RUN adduser --system --uid ${UID} expressjs
+# Copy only production worker payload instead of full builder workspace (just /prod/worker not entire /app)
COPY --from=prod-deps --chown=expressjs:expressjs /prod/worker ./worker
RUN chmod +x ./worker/entrypoint.sh
USER expressjs