examples: fix pnpm builds in Docker examples - #97217
Open
starmerx-liuba wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fix pnpm 11 dependency installation in the Node.js Docker variants of:
examples/with-dockerexamples/with-docker-export-outputThis change:
sharpto both examplespnpm-workspace.yamlinto all three pnpm-capable Docker dependency stagesDockerfile.servecopy optional.npmrcconfiguration consistently with the other Node.js DockerfilesWhy?
The Dockerfiles run
pnpm install --frozen-lockfile, but they do not provide an explicit build-script policy forsharp, 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:
The same installation pattern appears in three Dockerfiles:
examples/with-docker/Dockerfileexamples/with-docker-export-output/Dockerfileexamples/with-docker-export-output/Dockerfile.serveHow?
Each example now includes the following pnpm policy:
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.yamlbefore running the frozen installation.Dockerfile.servealso copies optional.npmrcconfiguration 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-dockerdocker build --no-cache -t nextjs-static-export examples/with-docker-export-outputdocker build --no-cache -f examples/with-docker-export-output/Dockerfile.serve -t nextjs-static-export-serve examples/with-docker-export-outputERR_PNPM_IGNORED_BUILDSis no longer reportedpnpm-lock.yamlfile changesgit diff --check