Skip to content

Commit

Permalink
👻 force npm9 during image build (#1781)
Browse files Browse the repository at this point in the history
Ever since the build container we use [1][2] updated to use `npm@10`,
the image builder github action has encountered a number of problems.
The first was solved with #1746. The second more random problem has been
with network connections erroring out when installing dependencies.

To work around the network and nofiles errors:
  1. enforce the use of `npm@9`
  2. pin the Dockerfile base images to specific version tags;
    builder at `:1-88`, and runtime at `:1-93`

Additional solutions:
  - Add the force to `npm@9` directly in the Dockerfile for use in all
    circumstances
  - Find a way to use something like verdaccio to proxy/mirror the npmjs
    repo during the build so npmjs fetches can be pooled across the parallel
    image builds

[1] registry.access.redhat.com/ubi9/nodejs-18:latest
[2] https://catalog.redhat.com/software/containers/ubi9/nodejs-18/62e8e7ed22d1d3c2dfe2ca01

---------

Signed-off-by: Scott J Dickerson <sdickers@redhat.com>
  • Loading branch information
sjd78 committed Mar 19, 2024
1 parent 984fbca commit da9da4c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
node-version: ${{ env.node-version }}
cache: "npm"

- name: Force install npm@9 to match Dockerfile build container ubi9/nodejs-18:1-88
run: npm install -g npm@9

- name: Verify package-lock.json
run: ./scripts/verify_lock.mjs

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
workflow_dispatch:
push:
branches:
- 'main'
- 'release-*'
- "main"
- "release-*"
tags:
- 'v*'
- "v*"

concurrency:
group: build-${{ github.ref }}
Expand All @@ -21,6 +21,7 @@ jobs:
image_name: "tackle2-ui"
containerfile: "./Dockerfile"
architectures: '[ "amd64", "arm64", "ppc64le", "s390x" ]'
# 2023-03-19: currently needed for npm@10
extra-args: "--ulimit nofile=4096:4096"
secrets:
registry_username: ${{ secrets.QUAY_PUBLISH_ROBOT }}
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# NOTE: Since the `:latest` tag can have npm version changes, we are using
# 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
# 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:latest as builder
FROM registry.access.redhat.com/ubi9/nodejs-18:1-88 as builder

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

# Runner image
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:latest
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-93

# Add ps package to allow liveness probe for k8s cluster
# Add tar package to allow copying files with kubectl scp
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"engines": {
"node": ">=18.14.2",
"npm": ">=9.5.0"
"npm": "^9.5.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down

0 comments on commit da9da4c

Please sign in to comment.