Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin node version #290

Merged
merged 1 commit into from Apr 3, 2024
Merged

Pin node version #290

merged 1 commit into from Apr 3, 2024

Conversation

gamingrobot
Copy link
Contributor

SWC library has changed and only installs the native components for the OS it was installed on (so we are missing alpine bits because we install on bookworm). Pinning to this version (and alpine) is a workaround for now.

@gamingrobot gamingrobot requested a review from a team as a code owner April 3, 2024 17:06
Copy link

github-actions bot commented Apr 3, 2024

Images built:

dotnet-core: ghcr.io/contrast-security-oss/agent-operator-images/agent-dotnet-core@sha256:0c1a57381722df6f308006729105267fa340ac7fb332abd8c69b8d1a5c247358
dotnet-framework: ghcr.io/contrast-security-oss/agent-operator-images/agent-dotnet-framework@sha256:4c56fd400a822ae6d993f119b74e432ddd892e455933b9945a801aeca4a020bf
java: ghcr.io/contrast-security-oss/agent-operator-images/agent-java@sha256:2de66dfd732286bf57f3786572c4c953be5f469daa25b0c5691307fde4aed49e
nodejs: ghcr.io/contrast-security-oss/agent-operator-images/agent-nodejs@sha256:c51b49e6c23a2ea64c807b0e95288db9e20ee5b2a114ff7379dc2163623848f6
php: ghcr.io/contrast-security-oss/agent-operator-images/agent-php@sha256:0138b031858f622d0f645b26bf96c8ad2c91fdd8c13b333bbc9ae970f53f2065
python: ghcr.io/contrast-security-oss/agent-operator-images/agent-python@sha256:3f80cd6cd3172e36f15a7e7fe1dc2b0f6b7f5794f9aa7d6628a8da56f1be15c4

@gamingrobot gamingrobot merged commit eea91f6 into master Apr 3, 2024
19 checks passed
@gamingrobot gamingrobot deleted the pin-nodejs-version branch April 3, 2024 17:11
@lkallas
Copy link

lkallas commented Apr 4, 2024

@gamingrobot
Hi! I was the one that noticed this problem when agent is being used in alpine linux and reported to Contrast Support.

I found out that the actual reason why agent (up to v5.4.1) Docker image is installing both libc variants (@swc/core-linux-x64-gnu and @swc/core-linux-x64-musl) is related to npm version the image is using.

The node:lts-bookworm-slim is using npm v10.5.0 while node:20.11.1-alpine is using npm v10.2.4

Refer to this issue and this comment where you can see that installing those 2 libc variants is actually a bug in npm.

It's fixed starting from npm v10.40.0 which means you will get only gnu variant with the latest node Docker images because it has the latest npm installed as well.

You could make the musl variant mandatory by adding it to package.json or you could force the usage of older npm in the Dockerfile:

npm install -g npm@10.2.4

@jcolekaplan
Copy link

Thank you @lkallas we came across the same thing and we're going to manually install both variants in the Dockerfile

-FROM node:20.11.1-alpine AS builder
+FROM node:lts-slim AS builder
 
 ARG VERSION=4.18.0
 
 RUN set -xe \
   && mkdir -p /contrast \
   && npm install --prefix /contrast @contrast/agent@${VERSION} \
+  && npm install --prefix /contrast @swc/core@1.3.39 --libc=glibc \
+  && npm install --prefix /contrast @swc/core@1.3.39 --libc=musl \
   && echo "{ \"version\": \"${VERSION}\" }" > /contrast/image-manifest.json

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.

None yet

3 participants