From 884c749039f16c7725b4b39aa97e2cdd381e7f7d Mon Sep 17 00:00:00 2001 From: Fergus Molloy Date: Fri, 25 Jul 2025 10:12:54 +0100 Subject: [PATCH] add rust-webapp container --- rust-webapp/Dockerfile | 18 ++++++++ rust-webapp/install-node.sh | 88 +++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 rust-webapp/Dockerfile create mode 100755 rust-webapp/install-node.sh diff --git a/rust-webapp/Dockerfile b/rust-webapp/Dockerfile new file mode 100644 index 0000000..e27909a --- /dev/null +++ b/rust-webapp/Dockerfile @@ -0,0 +1,18 @@ +FROM catthehacker/ubuntu:rust-latest +WORKDIR /app + +COPY . . + +# credit https://github.com/catthehacker/docker_images +RUN /app/install-node.sh + +RUN rm install-node.sh + +# download static bin +ADD https://get.nexte.st/latest/linux cargo-nextest.tar.gz + +# unpack and install +RUN tar xzf cargo-nextest.tar.gz -C ${CARGO_HOME:-~/.cargo}/bin + +# clean up +RUN rm cargo-nextest.tar.gz diff --git a/rust-webapp/install-node.sh b/rust-webapp/install-node.sh new file mode 100755 index 0000000..48c83a3 --- /dev/null +++ b/rust-webapp/install-node.sh @@ -0,0 +1,88 @@ +#!/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"