fix(docker): build on Node 20 LTS so the image compiles again#34
Merged
Conversation
The Docker CI build has been red since #31. The webpack-5 toolchain now needs Node 20+ — copy-webpack-plugin@14 calls Array.prototype.toSorted (Node >=20.9), which threw under the pinned node:16.13 base during `npm run build`. - Bump both builder and runtime stages to node:20-alpine (the app has been running and tested on Node 20.19/20.20 throughout development). - Node 20 ships npm 10, whose `npm ci` strictly enforces peer deps and rejects the lockfile (raw-loader@3 peer-requires webpack 4 while we run webpack 5). Add --legacy-peer-deps to both `npm ci` calls to match how the lockfile is resolved; switch the deprecated --production flag to --omit=dev. - Update engines.node to >=20.9.0 to reflect the real floor. Verified locally: `docker build` completes both stages; the resulting image boots (node v20.20.2) and serves HTTP 200 on /.
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.
Summary
The Docker CI build has been red since #31 (
Build (linux/amd64)andBuild (linux/arm64)both fail). This PR makes it green again.Root cause
The Dockerfile pinned
node:16.13-alpine3.13for both stages, but the webpack-5 toolchain now requires Node 20+:copy-webpack-plugin@14(introduced in chore(deps): clear npm audit findings (40 → 1) #31) callsArray.prototype.toSorted, a Node ≥20.9 method. Under Node 16 it threwTypeError: [...].toSorted is not a functionduringnpm run build, failing the build step.Fix
node:20-alpine. The app has been running and tested on Node 20.19/20.20 throughout development of chore(build): upgrade to webpack 5 #30–fix(test): repair frontend test suite under webpack 5 #33, so Node 20 is already proven for both build and runtime.--legacy-peer-depsto bothnpm cicalls. Node 20 ships npm 10, whosenpm cistrictly enforces peer deps and rejects the lockfile (raw-loader@3peer-requires webpack 4 while we run webpack 5). The lockfile is resolved with--legacy-peer-depseverywhere else; this matches it. Also switched the deprecated--productionto--omit=dev.engines.node→>=20.9.0to reflect the real floor.Why not downgrade copy-webpack-plugin instead?
It was bumped to 14 in #31 specifically to drop the vulnerable
serialize-javascript. The base image had to move off the EOL Node 16 regardless (evencopy-webpack-plugin@12needs Node ≥18.12), so moving to the Node 20 LTS we already test on is the cleaner direction.Test plan
docker build --platform linux/amd64 .— completes both stages, image exportednode v20.20.2) and serves HTTP 200 on/npm testgreen (pre-push hook ran on push, no--no-verify)