Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(devex): bound the pnpm download that stalls master image builds (#83777)

Julian Bez2766df47311c
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index 5ec8b6581e9b..3096e058fa62 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -45,8 +45,9 @@ jobs:
# Production build/deploy runs only from the canonical deploy repo (CD_DEPLOY_ENABLED).
if: github.repository_owner == 'PostHog' && vars.CD_DEPLOY_ENABLED == 'true'
runs-on: depot-ubuntu-24.04
- # Covers the build plus the post-build image-boot verification before dispatch.
- timeout-minutes: 40
+ # Covers two bounded build attempts plus the post-build image-boot verification before
+ # dispatch.
+ timeout-minutes: 60
permissions:
id-token: write # allow issuing OIDC tokens for this workflow run
contents: read # allow at least reading the repo contents, add other permissions if necessary
@@ -116,6 +117,9 @@ jobs:
id: build
if: steps.preflight.outputs.digest == ''
continue-on-error: true
+ # A hung build has to end as a step failure, not a job timeout: the retry ladder below
+ # is gated on `outcome == 'failure'`, and a cancelled job skips every step it guards.
+ timeout-minutes: 25
uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1.17.0
with:
context: . # match the CI build's context so master reuses the shared Depot layer cache
@@ -193,6 +197,7 @@ jobs:
id: build_retry
if: steps.build.outcome == 'failure' && steps.preflight_retry.outputs.digest == ''
continue-on-error: true
+ timeout-minutes: 25
uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1.17.0
with:
context: . # match the CI build's context so master reuses the shared Depot layer cache
diff --git a/.github/workflows/container-images-ci.yml b/.github/workflows/container-images-ci.yml
index dc614d61ff0d..89c23588b3c6 100644
--- a/.github/workflows/container-images-ci.yml
+++ b/.github/workflows/container-images-ci.yml
@@ -80,12 +80,15 @@ jobs:
# by the `hobby:` filter — workflow self-edits, `.dockerignore`
# (silently changes the build context), and `pnpm-lock.yaml` so
# Renovate-style dep bumps are exercised on PR (otherwise they'd
- # only fail after merging).
+ # only fail after merging). Root `package.json` carries the
+ # `packageManager` pin the image seeds corepack from, and a pin-only
+ # edit leaves the lockfile untouched.
build_inputs:
- .github/workflows/container-images-ci.yml
- .github/actions/build-n-cache-image/**
- .dockerignore
- pnpm-lock.yaml
+ - package.json
# Drives the fast PR-time guard below (models `COPY . .`, so it only reacts
# to .dockerignore — Dockerfile COPY changes are covered by the image boot check).
dockerignore:
diff --git a/Dockerfile b/Dockerfile
index 158f86847f6f..28b7da456af6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,6 +8,7 @@
#
# The stages are used to:
#
+# - node-base: shared Node.js base with pnpm already provisioned
# - frontend-build: build the frontend (static assets)
# - sourcemap-upload: upload sourcemaps to PostHog (isolated, no artifacts)
# - node-scripts-build: build plugin transpiler and other Node.js build artifacts
@@ -24,11 +25,25 @@
#
# ---------------------------------------------------------
#
-FROM node:24.13.0-bookworm-slim AS frontend-build
+FROM node:24.13.0-bookworm-slim AS node-base
WORKDIR /code
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
-COPY turbo.json package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
+# corepack fetches the pinned pnpm with a bare fetch() — no timeout, no retries — so a stalled
+# registry connection blocks until the job timeout kills the build. Seeding it here keeps that fetch
+# off every source change: only a root package.json edit re-runs this layer. Then take corepack off
+# the network, so a pin this layer does not cover fails in milliseconds naming the URL it wanted.
+COPY package.json ./
+RUN corepack enable && corepack install
+ENV COREPACK_ENABLE_NETWORK=0
+
+
+#
+# ---------------------------------------------------------
+#
+FROM node-base AS frontend-build
+
+COPY turbo.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
COPY frontend/package.json frontend/
COPY frontend/bin/ frontend/bin/
COPY bin/ bin/
@@ -42,7 +57,6 @@ COPY packages/llm-normalizer/ packages/llm-normalizer/
COPY products/ products/
COPY docs/onboarding/ docs/onboarding/
RUN --mount=type=cache,id=pnpm,target=/tmp/pnpm-store-v24 \
- corepack enable && pnpm --version && \
CI=1 pnpm --filter=@posthog/frontend... install --frozen-lockfile --store-dir /tmp/pnpm-store-v24
COPY frontend/ frontend/
@@ -123,17 +137,14 @@ RUN --mount=type=secret,id=posthog_upload_sourcemaps_cli_api_key \
#
# Build plugin transpiler and other Node.js build artifacts.
#
-FROM node:24.13.0-bookworm-slim AS node-scripts-build
-WORKDIR /code
-SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
+FROM node-base AS node-scripts-build
# Build plugin transpiler for site destinations/apps
-COPY turbo.json package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
+COPY turbo.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
COPY bin/turbo bin/turbo
COPY patches/ patches/
COPY common/esbuilder/ common/esbuilder/
COPY common/plugin_transpiler/ common/plugin_transpiler/
RUN --mount=type=cache,id=pnpm,target=/tmp/pnpm-store-v24 \
- corepack enable && \
NODE_OPTIONS="--max-old-space-size=4096" CI=1 pnpm --filter=@posthog/plugin-transpiler... install --frozen-lockfile --store-dir /tmp/pnpm-store-v24 && \
NODE_OPTIONS="--max-old-space-size=4096" bin/turbo --filter=@posthog/plugin-transpiler build
diff --git a/frontend/package.json b/frontend/package.json
index 38eb41f43a6f..63a109857456 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -379,6 +379,5 @@
},
"engines": {
"node": ">=24 <25"
- },
- "packageManager": "[email protected]"
+ }
}