refactor: update to node 22

This commit is contained in:
Rainer Killinger
2025-06-30 15:17:51 +02:00
parent ef4e1f8ded
commit c8e290200f
56 changed files with 14214 additions and 13224 deletions

View File

@@ -1,5 +1,5 @@
### Set base image
FROM ubuntu:20.04
FROM ubuntu:22.04
LABEL version="2.0.0" \
description="Build environment for the StApps app." \
@@ -8,18 +8,19 @@ LABEL version="2.0.0" \
### Configure versions to install
ENV ANDROID_APIS="android-34" \
ANDROID_BUILD_TOOLS_VERSION="34.0.0" \
NODE_VERSION="22.x" \
NPM_VERSION="^10.0.0" \
IONIC_VERSION="^6.0.0" \
IONIC_VERSION="^7.0.0" \
CAPACITOR_VERSION="^6.0.0" \
CORDOVA_RES_VERSION="latest" \
### Configure download URLs
ANDROID_SDK_TOOLS_DOWNLOAD_URL="https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip" \
ANDROID_SDK_TOOLS_DOWNLOAD_URL="https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" \
GOOGLE_SIGNING_KEY_URL="https://dl-ssl.google.com/linux/linux_signing_key.pub" \
GOOGLE_CHROME_REPOSITORY_URL="http://dl.google.com/linux/chrome/deb/" \
### Android SDK path
ANDROID_SDK_ROOT="/opt/android-sdk" \
### Installation files
SCRIPTS_DIRECTORY="scripts" \
NODE_SETUP_SCRIPT="node_setup.sh" \
TMP_PROJECT_NAME="tmp-project"
### Set $PATH
@@ -43,7 +44,7 @@ RUN apt-get update && \
git \
gradle \
ca-certificates-java \
python \
python3 \
python3-pip \
software-properties-common \
ssh \
@@ -54,9 +55,9 @@ RUN apt-get update && \
musl-dev \
&& rm -rf /var/lib/apt/lists/*
### Install Java Development Kit 17
### Install Java Development Kit 21
RUN add-apt-repository -y ppa:openjdk-r/ppa && apt-get update && \
apt-get install --no-install-recommends -y openjdk-17-jdk \
apt-get install --no-install-recommends -y openjdk-21-jdk \
&& rm -rf /var/lib/apt/lists/*
### Setup the locale
@@ -96,25 +97,25 @@ RUN curl $ANDROID_SDK_TOOLS_DOWNLOAD_URL > /tmp/android-sdk.zip && \
sdkmanager "platforms;$ANDROID_APIS" "build-tools;$ANDROID_BUILD_TOOLS_VERSION"
### Copy scripts directory into the tmp folder, so it's available to the following commands
COPY $SCRIPTS_DIRECTORY/$NODE_SETUP_SCRIPT /tmp/
RUN bash /tmp/$NODE_SETUP_SCRIPT && apt-get install -y nodejs && \
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash && \
apt-get install -y nodejs && \
### Install wanted npm version
npm install -g --unsafe-perm npm@$NPM_VERSION && \
### Install needed global npm packages
npm install -g --unsafe-perm @ionic/cli@$IONIC_VERSION cordova-res@$CORDOVA_RES_VERSION
npm install -g --unsafe-perm @ionic/cli@$IONIC_VERSION cordova-res@$CORDOVA_RES_VERSION @capacitor/cli@$CAPACITOR_VERSION
RUN cd / && ionic start $TMP_PROJECT_NAME blank --type=angular --capacitor --no-git --no-interactive && \
cd $TMP_PROJECT_NAME && ionic capacitor add android && export NG_CLI_ANALYTICS=ci && ionic capacitor build android --no-open && \
cd android && ./gradlew assembleDebug && \
cd / && rm -rf $TMP_PROJECT_NAME
cd $TMP_PROJECT_NAME && ionic capacitor add android && export NG_CLI_ANALYTICS=ci && ionic capacitor build android --no-open && \
cd android && ./gradlew assembleDebug && \
cd / && rm -rf $TMP_PROJECT_NAME
### Compatibility with musl libc
RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1
### PNPM
RUN corepack enable && corepack prepare pnpm@latest-8 --activate
RUN corepack enable && corepack prepare pnpm@latest-10 --activate
### Set working directory
WORKDIR /app

View File

@@ -1,108 +0,0 @@
#!/bin/bash
# Logger Function
log() {
local message="$1"
local type="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
local color
local endcolor="\033[0m"
case "$type" in
"info") color="\033[38;5;79m" ;;
"success") color="\033[1;32m" ;;
"error") color="\033[1;31m" ;;
*) color="\033[1;34m" ;;
esac
echo -e "${color}${timestamp} - ${message}${endcolor}"
}
# Error handler function
handle_error() {
local exit_code=$1
local error_message="$2"
log "Error: $error_message (Exit Code: $exit_code)" "error"
exit $exit_code
}
# Function to check for command availability
command_exists() {
command -v "$1" &> /dev/null
}
check_os() {
if ! [ -f "/etc/debian_version" ]; then
echo "Error: This script is only supported on Debian-based systems."
exit 1
fi
}
# Function to Install the script pre-requisites
install_pre_reqs() {
log "Installing pre-requisites" "info"
# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
fi
# Run 'apt-get install'
if ! apt-get install -y apt-transport-https ca-certificates curl gnupg; then
handle_error "$?" "Failed to install packages"
fi
if ! mkdir -p /usr/share/keyrings; then
handle_error "$?" "Makes sure the path /usr/share/keyrings exist or run ' mkdir -p /usr/share/keyrings' with sudo"
fi
rm -f /usr/share/keyrings/nodesource.gpg || true
rm -f /etc/apt/sources.list.d/nodesource.list || true
# Run 'curl' and 'gpg'
if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then
handle_error "$?" "Failed to download and import the NodeSource signing key"
fi
}
# Function to configure the Repo
configure_repo() {
local node_version=$1
arch=$(dpkg --print-architecture)
if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ] && [ "$arch" != "armhf" ]; then
handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64, and armhf are supported."
fi
echo "deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null
# N|solid Config
echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
# Nodejs Config
echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
# Run 'apt-get update'
if ! apt-get update -y; then
handle_error "$?" "Failed to run 'apt-get update'"
else
log "Repository configured successfully."
log "To install Node.js, run: apt-get install nodejs -y" "info"
log "You can use N|solid Runtime as a node.js alternative" "info"
log "To install N|solid Runtime, run: apt-get install nsolid -y \n" "success"
fi
}
# Define Node.js version
NODE_VERSION="18.x"
# Check OS
check_os
# Main execution
install_pre_reqs || handle_error $? "Failed installing pre-requisites"
configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository"

View File

@@ -1,5 +1,5 @@
### Set base image
FROM cypress/base:18.16.1
FROM cypress/base:22.16.0
USER root
@@ -61,9 +61,9 @@ ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
# install Firefox browser
RUN export FIREFOX_VERSION=$(curl -fsSL https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r '.LATEST_FIREFOX_VERSION') && \
wget --no-verbose -O /tmp/firefox.tar.bz2 "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2" && \
tar -C /opt -xjf /tmp/firefox.tar.bz2 && \
rm /tmp/firefox.tar.bz2 && \
wget --no-verbose -O /tmp/firefox.tar.xz "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.xz" && \
tar -C /opt -xJf /tmp/firefox.tar.xz && \
rm /tmp/firefox.tar.xz && \
ln -fs /opt/firefox/firefox /usr/bin/firefox
RUN echo "Downloading Latest Edge version..."
@@ -83,6 +83,9 @@ RUN apt-get update && \
# Add a link to the browser that allows Cypress to find it
RUN ln -s /usr/bin/microsoft-edge /usr/bin/edge
### PNPM
RUN corepack enable && corepack prepare pnpm@latest-10 --activate
# versions of local tools
RUN echo " node version: $(node -v) \n" \
"npm version: $(npm -v) \n" \

View File

@@ -1,7 +1,9 @@
FROM node:18-alpine3.18
FROM node:22-alpine
RUN apk update && apk add git curl jq && mkdir -p /opt
RUN corepack enable && corepack prepare pnpm@latest-10 --activate
COPY --chown=root:root wait-for.sh /opt/wait-for
RUN chmod +x /opt/wait-for && ln -s /opt/wait-for /usr/local/bin/wait-for

View File

@@ -1,7 +1,7 @@
FROM node:18-alpine3.18
FROM node:22-alpine
RUN apk update && apk add git jq curl python3 build-base
RUN npm install turbo pnpm --global
RUN npm install turbo --global && corepack enable && corepack prepare pnpm@latest-10 --activate
CMD []