From 7b18aeb19a20e7f5cc9d56d9b3d4d1cc1e839397 Mon Sep 17 00:00:00 2001 From: Fergus Molloy Date: Fri, 25 Jul 2025 13:56:53 +0100 Subject: [PATCH] use nvm way of installing nvm --- rust-webapp/Dockerfile | 14 ++++-- rust-webapp/install-node.sh | 88 ------------------------------------- 2 files changed, 10 insertions(+), 92 deletions(-) delete mode 100755 rust-webapp/install-node.sh diff --git a/rust-webapp/Dockerfile b/rust-webapp/Dockerfile index e27909a..6e43d22 100644 --- a/rust-webapp/Dockerfile +++ b/rust-webapp/Dockerfile @@ -1,12 +1,18 @@ FROM catthehacker/ubuntu:rust-latest WORKDIR /app -COPY . . +ARG NODE_VERSION=24 -# credit https://github.com/catthehacker/docker_images -RUN /app/install-node.sh +# install curl +RUN apt update && apt install curl -y -RUN rm install-node.sh +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash + +ENV NVM_DIR=/root/.nvm +RUN echo "NVM_DIR=/root/.nvm" | tee -a /etc/environment + +# install node +RUN bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" # download static bin ADD https://get.nexte.st/latest/linux cargo-nextest.tar.gz diff --git a/rust-webapp/install-node.sh b/rust-webapp/install-node.sh deleted file mode 100755 index 48c83a3..0000000 --- a/rust-webapp/install-node.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091,SC2174,SC2016 - -set -Eeuo pipefail - -. /etc/environment - -printf "\n\tšŸ‹ Installing NVM tools šŸ‹\t\n" -VERSION=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name') -curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh" | bash -export NVM_DIR=$HOME/.nvm -echo "NVM_DIR=$HOME/.nvm" | tee -a /etc/environment - -# Expressions don't expand in single quotes, use double quotes for that.shellcheck(SC2016) -# shellcheck disable=SC2016 -echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' | tee -a /etc/skel/.bash_profile - -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - -printf "\n\tšŸ‹ Installed NVM šŸ‹\t\n" -nvm --version - -# node 16 and 18 are already installed in act-* -versions=("24") -JSON=$(wget -qO- https://nodejs.org/download/release/index.json | jq --compact-output) - -for V in "${versions[@]}"; do - printf "\n\tšŸ‹ Installing NODE=%s šŸ‹\t\n" "${V}" - VER=$(echo "${JSON}" | jq "[.[] | select(.version|test(\"^v${V}\"))][0].version" -r) - NODEPATH="${ACT_TOOLSDIRECTORY}/node/${VER:1}/x64" - - mkdir -v -m 0777 -p "$NODEPATH" - ARCH=$(uname -m) - if [ "$ARCH" = x86_64 ]; then ARCH=x64; fi - if [ "$ARCH" = aarch64 ]; then ARCH=arm64; fi - wget -qO- "https://nodejs.org/download/release/latest-v${V}.x/node-$VER-linux-$ARCH.tar.xz" | tar -Jxf - --strip-components=1 -C "$NODEPATH" - - # ENVVAR="${V//\./_}" - # echo "${ENVVAR}=${NODEPATH}" >>/etc/environment - - printf "\n\tšŸ‹ Installed NODE šŸ‹\t\n" - "$NODEPATH/bin/node" -v -done - -# npm timeout under qemu with defaults -set -x -npm config set fetch-timeout 120000 -npm config set fetch-retry-mintimeout 120000 -npm config set fetch-retry-maxtimeout 120000 -npm config set prefer-offline true -npm config set registry http://registry.npmjs.org/ -npm config set maxsockets 4 -npm config set fetch-retries 4 -# Otherwise there are no log updates for 10m+ on qemu -npm config set loglevel verbose -npm config ls -l - -printf "\n\tšŸ‹ Installing JS tools šŸ‹\t\n" -npm install -g npm -npm install -g pnpm -npm install -g yarn -npm install -g grunt -npm install -g gulp -npm install -g n -npm install -g parcel-bundler -npm install -g typescript -npm install -g newman -npm install -g vercel -npm install -g webpack -npm install -g webpack-cli -npm install -g lerna -npm install -g --unsafe-perm netlify-cli - -printf "\n\tšŸ‹ Installed NPM šŸ‹\t\n" -npm -v - -printf "\n\tšŸ‹ Installed PNPM šŸ‹\t\n" -pnpm -v - -printf "\n\tšŸ‹ Installed YARN šŸ‹\t\n" -yarn -v - -printf "\n\tšŸ‹ Cleaning image šŸ‹\t\n" -apt-get clean -rm -rf /var/cache/* /var/log/* /var/lib/apt/lists/* /tmp/* || echo 'Failed to delete directories' -# remove npm config -npm config edit --editor rm -printf "\n\tšŸ‹ Cleaned up image šŸ‹\t\n"