Merge branch 'increase_nodejs_version' into admin_add_ai_chat

This commit is contained in:
einhornimmond 2025-03-15 10:41:16 +01:00
commit df224d3d9b
19 changed files with 88 additions and 50 deletions

View File

@ -6,7 +6,7 @@ GRAPHIQL=false
GDT_ACTIVE=false
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=

View File

@ -6,7 +6,7 @@ GRAPHIQL=false
GDT_API_URL=https://gdt.gradido.net
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=

View File

@ -8,7 +8,7 @@ GRAPHIQL=false
GDT_API_URL=$GDT_API_URL
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=$DB_USER
DB_PASSWORD=$DB_PASSWORD

View File

@ -1 +1 @@
v18.7.0
v18.20.7

View File

@ -1,4 +1,4 @@
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=

View File

@ -1,6 +1,6 @@
CONFIG_VERSION=$DATABASE_CONFIG_VERSION
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=$DB_USER
DB_PASSWORD=$DB_PASSWORD

View File

@ -1 +1 @@
v18.7.0
v18.20.7

View File

@ -1,7 +1,7 @@
##################################################################################
# BASE ###########################################################################
##################################################################################
FROM node:18.7.0-alpine3.16 as base
FROM node:18.20.7-alpine3.21 as base
# ENVs (available in production aswell, can be overwritten by commandline or env file)
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame

View File

@ -1,4 +1,12 @@
#!/bin/bash
# helper functions
log_step() {
local message="$1"
echo -e "\e[34m$message\e[0m" > /dev/tty # blue in console
echo "<p style="color:blue">$message</p>" >> "$UPDATE_HTML" # blue in html
}
# check for parameter
if [ -z "$1" ]; then
echo "Usage: Please provide a branch name as the first argument."
@ -75,12 +83,12 @@ TODAY=$(date +"%Y-%m-%d")
exec > >(tee -a $UPDATE_HTML) 2>&1
# configure nginx for the update-page
echo 'Configuring nginx to serve the update-page' >> $UPDATE_HTML
log_step 'Configuring nginx to serve the update-page'
ln -sf $SCRIPT_DIR/nginx/sites-available/update-page.conf $SCRIPT_DIR/nginx/sites-enabled/default
sudo /etc/init.d/nginx restart
# stop all services
echo 'Stop and delete all Gradido services' >> $UPDATE_HTML
log_step "Stop and delete all Gradido services"
pm2 delete all
pm2 save
# upgrade node js version
@ -91,7 +99,7 @@ npm install -g pm2 yarn
# git
BRANCH=$1
echo "Starting with git pull - branch:$BRANCH" >> $UPDATE_HTML
log_step "Starting with git pull - branch:$BRANCH"
cd $PROJECT_ROOT
# TODO: this overfetches alot, but ensures we can use start.sh with tags
git fetch --all
@ -104,7 +112,7 @@ export BUILD_COMMIT="$(git rev-parse HEAD)"
# *** set FEDERATION_PORT from FEDERATION_COMMUNITY_APIS and create gradido-federation.conf file
rm -f $NGINX_CONFIG_DIR/gradido.conf.tmp
rm -f $NGINX_CONFIG_DIR/gradido-federation.conf.locations
echo "====================================================================================================" >> $UPDATE_HTML
log_step "===================================================================================================="
IFS="," read -a API_ARRAY <<< $FEDERATION_COMMUNITY_APIS
for api in "${API_ARRAY[@]}"
do
@ -114,18 +122,18 @@ do
FEDERATION_PORT=${FEDERATION_COMMUNITY_API_PORT:-5000}
FEDERATION_PORT=$(($FEDERATION_PORT + $port))
export FEDERATION_PORT
echo "create ngingx config: location /api/$FEDERATION_APIVERSION to http://127.0.0.1:$FEDERATION_PORT" >> $UPDATE_HTML
log_step "create ngingx config: location /api/$FEDERATION_APIVERSION to http://127.0.0.1:$FEDERATION_PORT"
envsubst '$FEDERATION_APIVERSION, $FEDERATION_PORT' < $NGINX_CONFIG_DIR/gradido-federation.conf.template >> $NGINX_CONFIG_DIR/gradido-federation.conf.locations
done
unset FEDERATION_APIVERSION
unset FEDERATION_PORT
echo "====================================================================================================" >> $UPDATE_HTML
log_step "===================================================================================================="
# *** 2nd read gradido-federation.conf file in env variable to be replaced in 3rd step
export FEDERATION_NGINX_CONF=$(< $NGINX_CONFIG_DIR/gradido-federation.conf.locations)
# *** 3rd generate gradido nginx config including federation modules per api-version
echo 'Generate new gradido nginx config' >> $UPDATE_HTML
log_step 'Generate new gradido nginx config'
case "$URL_PROTOCOL" in
'https') TEMPLATE_FILE="gradido.conf.ssl.template" ;;
*) TEMPLATE_FILE="gradido.conf.template" ;;
@ -137,18 +145,20 @@ rm $NGINX_CONFIG_DIR/gradido.conf.tmp
rm $NGINX_CONFIG_DIR/gradido-federation.conf.locations
# Generate update-page.conf from template
echo 'Generate new update-page nginx config' >> $UPDATE_HTML
log_step 'Generate new update-page nginx config'
case "$URL_PROTOCOL" in
'https') TEMPLATE_FILE="update-page.conf.ssl.template" ;;
*) TEMPLATE_FILE="update-page.conf.template" ;;
esac
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $NGINX_CONFIG_DIR/$TEMPLATE_FILE > $NGINX_CONFIG_DIR/update-page.conf
log_step 'Clean tmp and yarn cache'
# Clean tmp folder - remove yarn files
find /tmp -name "yarn--*" -exec rm -r {} \;
# Clean user cache folder
rm -Rf ~/.cache/yarn
log_step 'Remove all node_modules and build folders'
# Remove node_modules folders
# we had problems with corrupted node_modules folder
rm -Rf $PROJECT_ROOT/database/node_modules
@ -169,6 +179,7 @@ rm -Rf $PROJECT_ROOT/admin/build
rm -Rf $PROJECT_ROOT/dht-node/build
rm -Rf $PROJECT_ROOT/federation/build
log_step 'Regenerate .env files'
# Regenerate .env files
cp -f $PROJECT_ROOT/database/.env $PROJECT_ROOT/database/.env.bak
cp -f $PROJECT_ROOT/backend/.env $PROJECT_ROOT/backend/.env.bak
@ -184,7 +195,7 @@ envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/dht-node/.env
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/federation/.env.template > $PROJECT_ROOT/federation/.env
# Install & build database
echo 'Updating database' >> $UPDATE_HTML
log_step 'Updating database'
cd $PROJECT_ROOT/database
yarn install
yarn build
@ -196,13 +207,13 @@ else
fi
# Install & build config
echo 'Updating config' >> $UPDATE_HTML
log_step 'Updating config'
cd $PROJECT_ROOT/config
yarn install
yarn build
# Install & build backend
echo 'Updating backend' >> $UPDATE_HTML
log_step 'Updating backend'
cd $PROJECT_ROOT/backend
# TODO maybe handle this differently?
unset NODE_ENV
@ -219,35 +230,27 @@ export NODE_ENV=production
# Install & build frontend
echo 'Updating frontend' >> $UPDATE_HTML
log_step 'Updating frontend'
cd $PROJECT_ROOT/frontend
# TODO maybe handle this differently?
unset NODE_ENV
nvm use
nvm install
npm i -g yarn
yarn install
yarn build
# TODO maybe handle this differently?
export NODE_ENV=production
# Install & build admin
echo 'Updating admin' >> $UPDATE_HTML
log_step 'Updating admin'
cd $PROJECT_ROOT/admin
# TODO maybe handle this differently?
unset NODE_ENV
nvm use
nvm install
npm i -g yarn
yarn install
yarn build
# TODO maybe handle this differently?
export NODE_ENV=production
nvm use default
# Install & build dht-node
echo 'Updating dht-node' >> $UPDATE_HTML
log_step 'Updating dht-node'
cd $PROJECT_ROOT/dht-node
# TODO maybe handle this differently?
unset NODE_ENV
@ -257,7 +260,7 @@ yarn build
export NODE_ENV=production
# Install & build federation
echo 'Updating federation' >> $UPDATE_HTML
log_step 'Updating federation'
cd $PROJECT_ROOT/federation
# TODO maybe handle this differently?
unset NODE_ENV
@ -276,34 +279,34 @@ if [ ! -z $FEDERATION_DHT_TOPIC ]; then
pm2 start --name gradido-dht-node "yarn --cwd $PROJECT_ROOT/dht-node start" -l $GRADIDO_LOG_PATH/pm2.dht-node.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
pm2 save
else
echo "=====================================================================" >> $UPDATE_HTML
echo "WARNING: FEDERATION_DHT_TOPIC not configured. DHT-Node not started..." >> $UPDATE_HTML
echo "=====================================================================" >> $UPDATE_HTML
fi
log_step "====================================================================="
log_step "WARNING: FEDERATION_DHT_TOPIC not configured. DHT-Node not started..."
log_step "====================================================================="
fi
# set FEDERATION_PORT from FEDERATION_COMMUNITY_APIS
IFS="," read -a API_ARRAY <<< $FEDERATION_COMMUNITY_APIS
for api in "${API_ARRAY[@]}"
do
export FEDERATION_API=$api
echo "FEDERATION_API=$FEDERATION_API" >> $UPDATE_HTML
log_step "FEDERATION_API=$FEDERATION_API"
export MODULENAME=gradido-federation-$api
echo "MODULENAME=$MODULENAME" >> $UPDATE_HTML
log_step "MODULENAME=$MODULENAME"
# calculate port by remove '_' and add value of api to baseport
port=${api//_/}
FEDERATION_PORT=${FEDERATION_COMMUNITY_API_PORT:-5000}
FEDERATION_PORT=$(($FEDERATION_PORT + $port))
export FEDERATION_PORT
echo "====================================================" >> $UPDATE_HTML
echo " start $MODULENAME listening on port=$FEDERATION_PORT" >> $UPDATE_HTML
echo "====================================================" >> $UPDATE_HTML
log_step "===================================================="
log_step " start $MODULENAME listening on port=$FEDERATION_PORT"
log_step "===================================================="
# pm2 delete $MODULENAME
pm2 start --name $MODULENAME "yarn --cwd $PROJECT_ROOT/federation start" -l $GRADIDO_LOG_PATH/pm2.$MODULENAME.$TODAY.log --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
pm2 save
done
# let nginx showing gradido
echo 'Configuring nginx to serve gradido again' >> $UPDATE_HTML
log_step 'Configuring nginx to serve gradido again'
ln -sf $SCRIPT_DIR/nginx/sites-available/gradido.conf $SCRIPT_DIR/nginx/sites-enabled/default
sudo /etc/init.d/nginx restart

View File

@ -124,11 +124,11 @@ sudo systemctl daemon-reload
# setup https with certbot
certbot certonly --nginx --non-interactive --agree-tos --domains $COMMUNITY_HOST --email $COMMUNITY_SUPPORT_MAIL
# Install node 16. with nvm, with nodesource is depracted
# Install node 18
sudo -u gradido bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'
# Close and reopen your terminal to start using nvm or run the following to use it now:
sudo -u gradido bash -c 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && nvm install 16' # first installed version will be set to default automatic
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && nvm install v18.20.7' # first installed version will be set to default automatic
# Install yarn
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && npm i -g yarn'

View File

@ -0,0 +1,15 @@
## Migrate from Gradido Version 2.5.1 to 2.5.2
### What
We need to upgrade the used nodejs version in deployment. Until now for pm2, backend, dht-node, federation nodejs 16 was used,
but some newer npm libs don't work with this old nodejs version so we upgrade to nodejs 18.20.7
### What you can do now
You need to only run this [upgradeNodeJs.sh](upgradeNodeJs.sh) with `release-2_5_2-beta` as parameter
```bash
cd /home/gradido/gradido/deployment/hetzner_cloud/migration/2_5_1-2_5_2
sudo ./upgradeNodeJs.sh `release-2_5_2-beta`
```
It will stop pm2, install new nodejs version + pm2 + yarn, remove nodejs 16.
Then it will call start.sh with first parameter of ./upgradeNodeJs.sh as his first parameter

View File

@ -0,0 +1,20 @@
#!/bin/bash
# check for parameter
if [ -z "$1" ]; then
echo "Usage: Please provide a branch name as the first argument."
exit 1
fi
# stop all services
pm2 delete all
pm2 save
# upgrade node js version
nvm install 18.20.7
nvm use 18.20.7
nvm alias default 18.20.7
npm install -g pm2 yarn
nvm uninstall 16
# Start gradido
sudo -u gradido $SCRIPT_PATH/start.sh $1

View File

@ -1,5 +1,5 @@
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=

View File

@ -2,7 +2,7 @@
CONFIG_VERSION=$FEDERATION_DHT_CONFIG_VERSION
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=$DB_USER
DB_PASSWORD=$DB_PASSWORD

View File

@ -67,7 +67,7 @@ services:
## MARIADB ##############################################
#########################################################
mariadb:
image: mariadb:10.5
image: mariadb:10.11.6
environment:
- MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1
- MARIADB_USER=root

View File

@ -1,5 +1,5 @@
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=gradido_community
DB_USER=root

View File

@ -6,7 +6,7 @@ LOG_LEVEL=$LOG_LEVEL
GRAPHIQL=false
# Database
DB_HOST=localhost
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=$DB_USER
DB_PASSWORD=$DB_PASSWORD

View File

@ -1 +1 @@
v18.7.0
v18.20.7

View File

@ -1,7 +1,7 @@
##################################################################################
# BASE ###########################################################################
##################################################################################
FROM node:18.7.0-alpine3.16 as base
FROM node:18.20.7-alpine3.21 as base
# ENVs (available in production aswell, can be overwritten by commandline or env file)
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame