Skip to content

Commit

Permalink
🌱 Update project to use nodejs 20, npm >=10.5.2 (#2062) (#2064)
Browse files Browse the repository at this point in the history
Upgrade the project to use nodejs-20 in the `Dockerfile`, and
package.json engine block. More specific entries for `.dockerignore`
will help keep the `COPY` step quick (especially for local dev image
builds).

Reasoning:
  - nodejs-18 is in LTS until May 2025, but nodejs-20 will be in LTS until
    May 2026. [^1]

  - node and npm are distributed together, and the `ubi9/nodejs-20`
    container has a newer version of npm included (10.7.0) than the current
    `ubi9/nodejs-18` container (10.5.0)

  - Given github issues [^2] and [^3], we can assume that the only
    versions of npm that will be stable in CI during the `npm install` phase
    are `npm@9` and `npm@>=10.5.2`. Any npm version <10.5.2 is at severe
    risk of encountering network errors when installing packages, especially
    when running in a qemu environment for non-native architecture builds.

  - Being very specific in the `package.json` `engines` block will help
    keep everyone on working versions of npm.

[^1]: https://nodejs.org/en/about/previous-releases
[^2]: npm/cli#7231
[^3]: npm/cli#7072

Backport-of: #2062
Signed-off-by: Scott J Dickerson <[email protected]>
  • Loading branch information
sjd78 authored Aug 28, 2024
1 parent 2b0ef6c commit 74daaf2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*/dist/
**/node_modules
**/dist
hack/
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
# a specific version tag. Container build errors have come up locally
# and via github action workflow when `:latest` is updated.
#
# Image info: https://catalog.redhat.com/software/containers/ubi9/nodejs-18/62e8e7ed22d1d3c2dfe2ca01
# Image info: https://catalog.redhat.com/software/containers/ubi9/nodejs-20/64770ac7a835530172eee6a9
# Relevant PRs:
# - https://github.com/konveyor/tackle2-ui/pull/1746
# - https://github.com/konveyor/tackle2-ui/pull/1781

# Builder image
FROM registry.access.redhat.com/ubi9/nodejs-18:1-118 as builder
FROM registry.access.redhat.com/ubi9/nodejs-20:1-54 as builder

USER 1001
COPY --chown=1001 . .
RUN npm clean-install --ignore-scripts && npm run build && npm run dist

RUN \
npm version && \
npm config ls && \
npm clean-install --verbose --ignore-scripts --no-audit && \
npm run build && \
npm run dist

# Runner image
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-123
FROM registry.access.redhat.com/ubi9/nodejs-20-minimal:1-57

# Add ps package to allow liveness probe for k8s cluster
# Add tar package to allow copying files with kubectl scp
Expand Down
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"client"
],
"engines": {
"node": ">=18.14.2",
"npm": ">=9.5.0"
"node": ">=20.12.2",
"npm": "^9.5.0 || ^10.5.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down

0 comments on commit 74daaf2

Please sign in to comment.