Skip to content

Commit

Permalink
Merge pull request #1437 from snyk/fix/upgrade-node
Browse files Browse the repository at this point in the history
fix: upgrade to Node v18 LTS
  • Loading branch information
popas90 authored Jan 10, 2024
2 parents 47d426d + d2191c6 commit bfc7d79
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 47 deletions.
30 changes: 15 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ commands:
sudo apt update
sudo apt install python3-requests
when: always
setup_node16:
description: Setup Node 16
setup_node:
description: Setup Node 18
steps:
- run:
command: |
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v16
nvm install v18
npm ci
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
echo 'nvm alias default v16' >> $BASH_ENV
echo 'nvm alias default v18' >> $BASH_ENV
jobs:
aks_integration_tests:
machine:
Expand All @@ -36,7 +36,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- azure-cli/install
- run:
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: |
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
steps:
- checkout
- install_python_requests
- setup_node16
- setup_node
- aws-cli/install:
override-installed: true
- run:
Expand All @@ -276,7 +276,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/kind
Expand All @@ -301,7 +301,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/kind-helm
Expand All @@ -326,7 +326,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
Expand All @@ -353,7 +353,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/proxy
Expand All @@ -377,7 +377,7 @@ jobs:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: |
Expand All @@ -396,7 +396,7 @@ jobs:
resource_class: large
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/openshift4
Expand Down Expand Up @@ -945,7 +945,7 @@ jobs:
image: ubuntu-2204:2022.04.1
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: |
Expand Down Expand Up @@ -997,7 +997,7 @@ jobs:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- snyk/scan:
additional-arguments: --all-projects --exclude=test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
description: Setup Node 16
description: Setup Node 18
steps:
- run:
command: |
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v16
nvm install v18
npm ci
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
echo 'nvm alias default v16' >> $BASH_ENV
echo 'nvm alias default v18' >> $BASH_ENV
18 changes: 9 additions & 9 deletions .circleci/config/jobs/@jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lint:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: |
Expand All @@ -22,7 +22,7 @@ code_formatter:
image: ubuntu-2004:202111-01
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: |
Expand All @@ -41,7 +41,7 @@ unit_tests:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- snyk/scan:
additional-arguments: --all-projects --exclude=test
Expand Down Expand Up @@ -73,7 +73,7 @@ system_tests:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
name: Install Skopeo
Expand All @@ -100,7 +100,7 @@ integration_tests:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
name: create temp dir for logs
Expand All @@ -126,7 +126,7 @@ integration_tests_helm:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
name: Create temporary directory for logs
Expand All @@ -152,7 +152,7 @@ integration_tests_proxy:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
name: Create temporary directory for logs
Expand All @@ -179,7 +179,7 @@ eks_integration_tests:
steps:
- checkout
- install_python_requests
- setup_node16
- setup_node
- aws-cli/install:
override-installed: true
- run:
Expand Down Expand Up @@ -207,7 +207,7 @@ aks_integration_tests:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- azure-cli/install
- run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ machine:
docker_layer_caching: true
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
command: mkdir -p /tmp/logs/test/integration/kind-olm-operator
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config/jobs/openshift4_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ machine:
working_directory: ~/kubernetes-monitor
steps:
- checkout
- setup_node16
- setup_node
- install_python_requests
- run:
name: create temp dir for logs
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN go install github.com/chrismellard/docker-credential-acr-env@82a0ddb2758901b
#---------------------------------------------------------------------
# STAGE 2: Build the kubernetes-monitor
#---------------------------------------------------------------------
FROM node:gallium-alpine
FROM node:hydrogen-alpine

LABEL name="Snyk Controller" \
maintainer="support@snyk.io" \
Expand Down
17 changes: 8 additions & 9 deletions Dockerfile.ubi9
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#---------------------------------------------------------------------
# STAGE 1: Build kubernetes-monitor application
#---------------------------------------------------------------------
FROM --platform=linux/amd64 registry.access.redhat.com/ubi8/nodejs-16:1-118 AS build
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/nodejs-18:1-84 AS build

ENV NODE_ENV production

# Add manifest files and install before adding anything else to take advantage of layer caching
COPY --chown=1001:1001 package.json package-lock.json ./

RUN npm config set unsafe-perm true
RUN npm ci

# add the rest of the app files
Expand All @@ -31,8 +30,8 @@ RUN dnf install -y containers-common
#---------------------------------------------------------------------
FROM --platform=linux/amd64 registry.access.redhat.com/ubi9/ubi:9.2

ARG NODE_16_LATEST_VERSION
ARG NODE_16_LATEST_VERSION_TAR_GZ_FILE_SHASUM256
ARG NODE_18_LATEST_VERSION
ARG NODE_18_LATEST_VERSION_TAR_GZ_FILE_SHASUM256
# https://github.com/Yelp/dumb-init/releases
ARG DUMB_INIT_VERSION=1.2.5
ARG DUMB_INIT_BINARY_FILE_SHASUM256=e874b55f3279ca41415d290c512a7ba9d08f98041b28ae7c2acb19a545f1c4df
Expand Down Expand Up @@ -92,11 +91,11 @@ RUN curl -sSfL https://sdk.cloud.google.com | bash -s -- --disable-prompts --ins
ENV PATH=/google-cloud-sdk/bin:$PATH

# Install node
RUN curl -sSfLo /tmp/node_16.tar.gz "https://nodejs.org/dist/latest-v16.x/${NODE_16_LATEST_VERSION}.tar.gz" && \
echo "${NODE_16_LATEST_VERSION_TAR_GZ_FILE_SHASUM256} /tmp/node_16.tar.gz" | sha256sum --check --status && \
mkdir /tmp/node_16 && tar -C /tmp/node_16 -xzf /tmp/node_16.tar.gz ${NODE_16_LATEST_VERSION}/bin/node && \
mv /tmp/node_16/${NODE_16_LATEST_VERSION}/bin/node /usr/local/bin && \
rm -rf /tmp/node_16.tar.gz /tmp/node_16
RUN curl -sSfLo /tmp/node_18.tar.gz "https://nodejs.org/dist/latest-v18.x/${NODE_18_LATEST_VERSION}.tar.gz" && \
echo "${NODE_18_LATEST_VERSION_TAR_GZ_FILE_SHASUM256} /tmp/node_18.tar.gz" | sha256sum --check --status && \
mkdir /tmp/node_18 && tar -C /tmp/node_18 -xzf /tmp/node_18.tar.gz ${NODE_18_LATEST_VERSION}/bin/node && \
mv /tmp/node_18/${NODE_18_LATEST_VERSION}/bin/node /usr/local/bin && \
rm -rf /tmp/node_18.tar.gz /tmp/node_18

RUN rpm -e --nodeps curl-minimal && \
rpm -e --nodeps libcurl-minimal
Expand Down
14 changes: 7 additions & 7 deletions scripts/docker/build-image-ubi9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ LOCAL_DISCARDABLE_IMAGE=snyk/kubernetes-monitor:ubi9
# should happen on merging to `staging`
NAME_AND_TAG=${1:-$LOCAL_DISCARDABLE_IMAGE}

# This step gets the latest version of node 16 from node.js. It removes the .tar.gz extension and then returns the result.
# It is used when buidling the ubi image in order to download the latest node 16 version and copy its binary.
NODE_16_LATEST_VERSION_TAR_GZ_FILE=$(curl --fail --silent https://nodejs.org/dist/latest-v16.x/SHASUMS256.txt | grep linux-x64.tar.gz | awk '{ print $2 }')
NODE_16_LATEST_VERSION="${NODE_16_LATEST_VERSION_TAR_GZ_FILE%%.tar.gz}"
NODE_16_LATEST_VERSION_TAR_GZ_FILE_SHASUM256=$(curl --fail --silent https://nodejs.org/dist/latest-v16.x/SHASUMS256.txt | grep linux-x64.tar.gz | awk '{ print $1 }')
# This step gets the latest version of node 18 from node.js. It removes the .tar.gz extension and then returns the result.
# It is used when buidling the ubi image in order to download the latest node 18 version and copy its binary.
NODE_18_LATEST_VERSION_TAR_GZ_FILE=$(curl --fail --silent https://nodejs.org/dist/latest-v18.x/SHASUMS256.txt | grep linux-x64.tar.gz | awk '{ print $2 }')
NODE_18_LATEST_VERSION="${NODE_18_LATEST_VERSION_TAR_GZ_FILE%%.tar.gz}"
NODE_18_LATEST_VERSION_TAR_GZ_FILE_SHASUM256=$(curl --fail --silent https://nodejs.org/dist/latest-v18.x/SHASUMS256.txt | grep linux-x64.tar.gz | awk '{ print $1 }')

docker build \
--build-arg NODE_16_LATEST_VERSION="${NODE_16_LATEST_VERSION}" \
--build-arg NODE_16_LATEST_VERSION_TAR_GZ_FILE_SHASUM256="${NODE_16_LATEST_VERSION_TAR_GZ_FILE_SHASUM256}" \
--build-arg NODE_18_LATEST_VERSION="${NODE_18_LATEST_VERSION}" \
--build-arg NODE_18_LATEST_VERSION_TAR_GZ_FILE_SHASUM256="${NODE_18_LATEST_VERSION_TAR_GZ_FILE_SHASUM256}" \
-t ${NAME_AND_TAG} \
--file=Dockerfile.ubi9 .

Expand Down

0 comments on commit bfc7d79

Please sign in to comment.