fix: fix pnpm builds in Docker examples (#97352)
## What? Fix pnpm 11 dependency installation in the Node.js Docker variants of: - `examples/with-docker` - `examples/with-docker-export-output` This change: - adds a narrowly scoped pnpm build policy for `sharp` to both examples - copies `pnpm-workspace.yaml` into all three pnpm-capable Docker dependency stages - makes `Dockerfile.serve` copy optional `.npmrc` configuration consistently with the other Node.js Dockerfiles ## Why? The Dockerfiles run `pnpm install --frozen-lockfile`, but they do not provide an explicit build-script policy for `sharp`, an optional Next.js dependency. With pnpm 11, dependency build scripts require an explicit decision. The documented Docker build consequently exits during dependency installation with: ```text ERR_PNPM_IGNORED_BUILDS Ignored build scripts: sharp@0.34.5 Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts. ``` The same installation pattern appears in three Dockerfiles: - `examples/with-docker/Dockerfile` - `examples/with-docker-export-output/Dockerfile` - `examples/with-docker-export-output/Dockerfile.serve` ## How? Each example now includes the following pnpm policy: ```yaml allowBuilds: sharp: false ``` This records an explicit decision not to run Sharp's lifecycle script. Sharp provides prebuilt binaries for the platforms supported by Next.js, so the Docker examples do not need to grant the script permission to execute. Each affected dependency stage copies `pnpm-workspace.yaml` before running the frozen installation. `Dockerfile.serve` also copies optional `.npmrc` configuration for consistency. The npm and Yarn installation branches are unchanged, and the Bun Dockerfile is unaffected. ## Validation - [x] `docker build --no-cache -t nextjs-standalone-image examples/with-docker` - [x] `docker build --no-cache -t nextjs-static-export examples/with-docker-export-output` - [x] `docker build --no-cache -f examples/with-docker-export-output/Dockerfile.serve -t nextjs-static-export-serve examples/with-docker-export-output` - [x] Confirmed that `ERR_PNPM_IGNORED_BUILDS` is no longer reported - [x] Confirmed that neither `pnpm-lock.yaml` file changes - [x] `git diff --check` <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment