Skip to content

examples: fix pnpm builds in Docker examples - #97217

Open
starmerx-liuba wants to merge 1 commit into
vercel:canaryfrom
starmerx-liuba:fix/pnpm-builds-in-docker-examples
Open

examples: fix pnpm builds in Docker examples#97217
starmerx-liuba wants to merge 1 commit into
vercel:canaryfrom
starmerx-liuba:fix/pnpm-builds-in-docker-examples

Conversation

@starmerx-liuba

Copy link
Copy Markdown

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:

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:

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

  • docker build --no-cache -t nextjs-standalone-image examples/with-docker
  • docker build --no-cache -t nextjs-static-export examples/with-docker-export-output
  • docker build --no-cache -f examples/with-docker-export-output/Dockerfile.serve -t nextjs-static-export-serve examples/with-docker-export-output
  • Confirmed that ERR_PNPM_IGNORED_BUILDS is no longer reported
  • Confirmed that neither pnpm-lock.yaml file changes
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants