fix: repair docker build by pinning pnpm and approving dependency build scripts - #30
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @nyeinphyoaung's task in 2m 30s —— View job Code Review: fix: repair docker build by pinning pnpm and approving dependency build scriptsSummaryThis is a small, well-scoped infra fix that pins the package manager and re-approves the native build scripts pnpm 11 now hard-blocks by default. The author's manual verification (clean Medium Issues1. No CI coverage for the Docker build (
|
|
Claude finished @nyeinphyoaung's task in 2m 13s —— View job Code Review: fix: repair docker build by pinning pnpm and approving dependency build scriptsSummaryThis is a small, well-scoped infra fix that correctly root-causes the Medium Issues1. No CI coverage for the Docker build (
|
The problem
docker compose buildfailed atpnpm install --frozen-lockfilewithERR_PNPM_IGNORED_BUILDS.Nothing in the repo caused it. The Dockerfile ran
corepack prepare pnpm@latest --activate, so the container silently moved to pnpm 11.22.0 when it was released, while local development was still on pnpm 10.20.0. pnpm 11 turns "ignored dependency build scripts" from a warning into a hard error, so the install exited 1 and the image could not be built at all.Fixes
1. Pin the package manager so the container, CI and local machines all resolve the same pnpm:
The Dockerfile now uses plain
corepack enable, which honours that field instead of fetching whatever is newest. Build log confirmsDone in 46.8s using pnpm v11.22.0.2. Approve the dependency build scripts that genuinely need to run, in
pnpm-workspace.yaml:sharpcompiles the native libvips binary used bynext/image(5 files in the app use it)esbuildfetches its platform binary, needed bytsx/drizzle-kitfor thedb:*scriptsunrs-resolveris a native binding for the ESLint import resolverThis is the documented pnpm 11 format, not a workaround. Per pnpm's build settings reference,
allowBuildswas added in v10.26.0 and takes a package-to-boolean map inpnpm-workspace.yaml. The docs state thatonlyBuiltDependencies,onlyBuiltDependenciesFile,neverBuiltDependencies,ignoredBuiltDependenciesandignoreDepScriptswere removed in v11 and replaced byallowBuilds, withonlyBuiltDependencies: [electron]converting toallowBuilds: {electron: true}.That also explains the two dead ends hit on the way here:
onlyBuiltDependenciesinpackage.jsonis ignored outright by pnpm 11, and the same key inpnpm-workspace.yamlis still readable viapnpm config getbut no longer gates the install.pnpm approve-builds --allgenerates the correct form.3. Copy the config into the image. The deps stage only copied two files, so the container never saw the new config:
4.
ENV HUSKY=0in the deps stage..dockerignoreexcludes.git, soprepare: huskyfailed noisily on every build. The variable already existed but only in the builder stage, after install had run.5. Removed the stale
GOOGLE_GENERATIVE_AI_API_KEYbuild arg from both the Dockerfile and compose file, left over from the removed AI integration.Verification
Built clean with
--no-cache, then run and exercised:Ready, no errors in logs/and/sign-inreturn 200;/dashboardand/ai-chatreturn 307 to sign-in (auth gating correct)POST /api/auth/sign-in/emailreturns the seeded user and a session token, so the container reaches Postgressharpis present in the runtime image, so image optimisation worksdocker inspectenv and layer history are clean, since the multi-stage build discards the builder stagepnpm-lock.yamlis unchanged.Consequence worth knowing
Corepack will now switch anyone in this repo to pnpm 11.22.0 automatically. That is the intent - it is what stops the version drifting again - but upgrading pnpm in future means bumping that line rather than just installing a newer version globally.