Runtime 2020.08-1

* New versions of PHP, Node.js and Python
* Updated rosti.sh to support arguments
This commit is contained in:
Adam Štrauch 2020-08-23 00:49:52 +02:00
parent b54c01cadd
commit 31e63245e1
Signed by: cx
GPG Key ID: 018304FFA8988F8D
5 changed files with 231 additions and 176 deletions

View File

@ -45,28 +45,27 @@ ENV TERM xterm
WORKDIR /usr/src WORKDIR /usr/src
ADD build_node.sh /usr/local/bin/build_node.sh ADD build_node.sh /usr/local/bin/build_node.sh
# 2020/01 # 2020/01
RUN build_node.sh 13.7.0
RUN build_node.sh 13.12.0 RUN build_node.sh 13.12.0
RUN build_node.sh 14.8.0
# 2020/01 # 2020/01
RUN build_node.sh 12.14.1
RUN build_node.sh 12.16.1 RUN build_node.sh 12.16.1
RUN build_node.sh 12.18.3
## Python ## Python
WORKDIR /usr/src WORKDIR /usr/src
ADD build_python.sh /usr/local/bin/build_python.sh ADD build_python.sh /usr/local/bin/build_python.sh
# 2020/01 # 2020/01
RUN build_python.sh 3.8.1
RUN build_python.sh 3.8.2 RUN build_python.sh 3.8.2
RUN build_python.sh 3.8.5
## PHP ## PHP
WORKDIR /usr/src WORKDIR /usr/src
ADD build_php.sh /usr/local/bin/build_php.sh ADD build_php.sh /usr/local/bin/build_php.sh
# 2020/01 # 2020/01
RUN build_php.sh 7.2.29
RUN build_php.sh 7.4.2
RUN build_php.sh 7.4.4 RUN build_php.sh 7.4.4
RUN build_php.sh 7.4.9
## Roští script ## Roští script

View File

@ -1,5 +1,5 @@
DOCKER=docker DOCKER=docker
VERSION=2020.05-1 VERSION=2020.08-1
all: build all: build

View File

@ -10,15 +10,14 @@ The image is based on Debian 10 Buster and it's size is around 2.5 GB when it's
** Supported languages ** ** Supported languages **
* Python 3.8.1
* Python 3.8.2 * Python 3.8.2
* Node.js 13.7.0 * Python 3.8.5
* Node.js 13.12.0 * Node.js 13.12.0
* Node.js 14.8.0
* Node.js 12.14.1 * Node.js 12.14.1
* Node.js 12.16.1 * Node.js 12.16.1
* PHP 7.2.29
* PHP 7.4.2
* PHP 7.4.4 * PHP 7.4.4
* PHP 7.4.9
** Additional tools ** ** Additional tools **

319
rosti.sh
View File

@ -8,6 +8,15 @@ HEIGHT=25
TECHDIR=/opt/techs TECHDIR=/opt/techs
PRIMARYDIR=/srv/bin/primary_tech PRIMARYDIR=/srv/bin/primary_tech
# Usage: rosti php|python|node|memcached|redis OPTINAL_VERSION
#
# This script helps to configure the environment for selected
# language/technology/service. The language or service can be
# selected via TUI menu or optinal arguments.
QUICK_TECH=$1
QUICK_VERSION=$2
# These environment variables can be set for testing: # These environment variables can be set for testing:
# TESTMODE - 1 if test mode is enabled, it skips whiptail # TESTMODE - 1 if test mode is enabled, it skips whiptail
# MENUITEM - selected menu item # MENUITEM - selected menu item
@ -15,13 +24,183 @@ PRIMARYDIR=/srv/bin/primary_tech
# SERVICE - selected service # SERVICE - selected service
function setTech() {
tech=$1
# Activation of primary tech bin directory
test ! -e $PRIMARYDIR || unlink $PRIMARYDIR
ln -s $TECHDIR/$tech/bin $PRIMARYDIR
# Parse name of the tech - like python or node
name=`echo $tech | cut -d"-" -f 1`
# If /srv/app doesn't exist we will use examples files to create it
if [ ! -e /srv/app ]; then
mkdir -p /srv/conf/supervisor.d
echo "NOTE: /srv/app doesn't exists, creating it from $tech example application"
mkdir -p /srv/app
cp -a /opt/examples/$name/* /srv/app/
mv /srv/app/supervisor.conf /srv/conf/supervisor.d/$name.conf
else
echo "IMPORTANT: /srv/app found so no configuration or files are copied, make sure the application is ok after this process"
fi
# Pythoon specific stuff
if [ "$name" = "python" ]; then
if [ -e /srv/venv ]; then
echo "IMPORTANT: /srv/venv exists, if you have changed python version, make sure to create or update the virtualenv:"
echo
echo " rm -rf /srv/venv"
echo " python3 -m venv /srv/venv)"
echo
echo "Don't forget to backup the old venv if necessary."
else
echo ".. creating new venv in /srv/venv"
test -e /srv/venv || $PRIMARYDIR/python3 -m venv /srv/venv
/srv/venv/bin/pip install gunicorn
/srv/venv/bin/pip install bottle
fi
fi
# PHP specific stuff
if [ "$name" = "php" ]; then
mkdir -p /srv/conf/php-fpm/pool.d/
# Copy config if needed
test -e /srv/conf/php-fpm/php-fpm.conf || mv /srv/app/php-fpm.conf /srv/conf/php-fpm/php-fpm.conf
test -e /srv/conf/php-fpm/pool.d/app.conf || mv /srv/app/pool_app.conf /srv/conf/php-fpm/pool.d/app.conf
test -e /srv/conf/php-fpm/php.ini || mv /srv/app/php.ini /srv/conf/php-fpm/php.ini
ln -s /srv/conf/php-fpm/php.ini /opt/techs/$tech/etc/conf.d/app.ini
# And remove unneeded ones
# TODO: not sure how good idea this is
rm -f /srv/app/php-fpm.conf /srv/app/pool_app.conf /srv/app/php.ini /srv/app/nginx.conf
fi
# Node specific stuff
if [ "$name" = "node" ]; then
/opt/techs/$tech/bin/npm config set prefix "/srv/.npm-packages"
/opt/techs/$tech/bin/npm install -g yarn@berry
fi
# Remove default config in Nginx
test -e /srv/conf/nginx.d/default.conf && rm -f /srv/conf/nginx.d/default.conf
# Same thing we do for nginx but if the file exist it's not rewritten.
if [ ! -e /srv/conf/nginx.d/app.conf ]; then
mkdir -p /srv/conf/nginx.d
if [ "$name" = "php" ]; then
cp /opt/examples/php/nginx.conf /srv/conf/nginx.d/app.conf
else
cp /opt/examples/nginx/nginx.conf /srv/conf/nginx.d/app.conf
fi
echo ".. app configuration for nginx not found, adding it - please check /srv/conf/nginx.d/app.conf and make sure it fits your code"
fi
# We load new configuration into supervisor and it's automatically started or restarted if needed
supervisorctl reread
supervisorctl update
nginx -s reload
echo "NOTE: this tool doesn't restart existing processes, if it's needed, please, do it manually"
echo
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
}
function setService() {
service=$1
case $service in
"redis")
echo ".. adding redis into supervisor and copying config file into /srv/conf/redis.conf"
mkdir -p /srv/var/redis
cp /opt/examples/redis/supervisor.conf /srv/conf/supervisor.d/redis.conf
cp /opt/examples/redis/redis.conf /srv/conf/redis.conf
supervisorctl reread
supervisorctl update
echo "NOTE: please, check configuration file /srv/conf/redis.conf and update it if needed"
echo "NOTE: Redis server is available at localhost:6379"
echo
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;;
"memcached")
echo ".. adding memcached into supervisor"
cp /opt/examples/memcached/supervisor.conf /srv/conf/supervisor.d/memcached.conf
supervisorctl reread
supervisorctl update
echo "NOTE: Memcached server is available at localhost:11211"
echo
if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;;
"*")
continue
;;
esac
}
# Use two parameters to handle everything this script allows to user
function quickTech() {
TECH=$1
VERSION=$2
case $TECH in
"python")
if [ -z "$VERSION" ]; then
VERSION=3.8.5
fi
setTech $TECH-$VERSION
;;
"php")
if [ -z "$VERSION" ]; then
VERSION=7.4.9
fi
setTech $TECH-$VERSION
;;
"node")
if [ -z "$VERSION" ]; then
VERSION=14.8.0
fi
setTech $TECH-$VERSION
;;
"memcached")
setService $TECH
;;
"redis")
setService $TECH
;;
esac
}
# If parameters with tech and possibly version are given we just use those
if [ -n "$QUICK_TECH" ]; then
quickTech $QUICK_TECH $QUICK_VERSION
exit 0
fi
# We will use EDITOR environment variables if possible # We will use EDITOR environment variables if possible
if [ "$EDITOR" = "" ]; then if [ "$EDITOR" = "" ]; then
export EDITOR=nano export EDITOR=nano
fi fi
while /bin/true; do while /bin/true; do
if [ ! "$TESTMODE" = "1" ]; then if [ "$MENUITEM" = "" ]; then
menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 6 \ menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 6 \
"tech" " Activaton of primary tech" \ "tech" " Activaton of primary tech" \
"services" " Enable additional services (Redis, Memcached, ..)" \ "services" " Enable additional services (Redis, Memcached, ..)" \
@ -36,17 +215,16 @@ while /bin/true; do
# Activation of one of the available tech # Activation of one of the available tech
# Only one tech can be enabled same time but it's possible to use any of them from /opt/techs # Only one tech can be enabled same time but it's possible to use any of them from /opt/techs
"tech") "tech")
if [ ! "$TESTMODE" = "1" ]; then if [ "$TECH" = "" ]; then
tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 6 \ tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 6 \
"python-3.8.1" " Python 3.8.1" \
"python-3.8.2" " Python 3.8.2" \ "python-3.8.2" " Python 3.8.2" \
"node-13.7.0" " Node 13.7.0" \ "python-3.8.5" " Python 3.8.5" \
"node-13.12.0" " Node 13.12.0" \ "node-13.12.0" " Node 13.12.0" \
"node-12.14.1" " Node 12.14.1" \ "node-14.8.0" " Node 14.8.0" \
"node-12.16.1" " Node 12.16.1" \ "node-12.16.1" " Node 12.16.1" \
"php-7.2.29" " PHP 7.2.29" \ "node-12.18.3" " Node 12.18.3" \
"php-7.4.2" " PHP 7.4.2" \
"php-7.4.4" " PHP 7.4.4" \ "php-7.4.4" " PHP 7.4.4" \
"php-7.4.9" " PHP 7.4.9" \
"back" " Go back" \ "back" " Go back" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
else else
@ -57,95 +235,11 @@ while /bin/true; do
continue continue
fi fi
# Activation of primary tech bin directory setTech $tech
test ! -e $PRIMARYDIR || unlink $PRIMARYDIR
ln -s $TECHDIR/$tech/bin $PRIMARYDIR
# Parse name of the tech - like python or node
name=`echo $tech | cut -d"-" -f 1`
# If /srv/app doesn't exist we will use examples files to create it
if [ ! -e /srv/app ]; then
mkdir -p /srv/conf/supervisor.d
echo "NOTE: /srv/app doesn't exists, creating from $tech example application"
mkdir -p /srv/app
cp -a /opt/examples/$name/* /srv/app/
mv /srv/app/supervisor.conf /srv/conf/supervisor.d/$name.conf
else
echo "IMPORTANT: /srv/app found so no configuration or files are copied, make sure the application is ok after its process is restarted"
fi
# Pythoon specific stuff
if [ "$name" = "python" ]; then
if [ -e /srv/venv ]; then
echo "IMPORTANT: /srv/venv exists, if you have changed python version, make sure to create or update the virtualenv:"
echo
echo " rm -rf /srv/venv"
echo " python3 -m venv /srv/venv)"
echo
echo "Don't forget to backup the old venv if necessary."
else
echo ".. creating new venv in /srv/venv"
test -e /srv/venv || $PRIMARYDIR/python3 -m venv /srv/venv
/srv/venv/bin/pip install gunicorn
/srv/venv/bin/pip install bottle
fi
fi
# PHP specific stuff
if [ "$name" = "php" ]; then
mkdir -p /srv/conf/php-fpm/pool.d/
# Copy config if needed
test -e /srv/conf/php-fpm/php-fpm.conf || mv /srv/app/php-fpm.conf /srv/conf/php-fpm/php-fpm.conf
test -e /srv/conf/php-fpm/pool.d/app.conf || mv /srv/app/pool_app.conf /srv/conf/php-fpm/pool.d/app.conf
test -e /srv/conf/php-fpm/php.ini || mv /srv/app/php.ini /srv/conf/php-fpm/php.ini
ln -s /srv/conf/php-fpm/php.ini /opt/techs/$tech/etc/conf.d/app.ini
# And remove unneeded ones
# TODO: not sure how good idea this is
rm -f /srv/app/php-fpm.conf /srv/app/pool_app.conf /srv/app/php.ini /srv/app/nginx.conf
fi
# Node specific stuff
if [ "$name" = "node" ]; then
/opt/techs/$tech/bin/npm config set prefix "/srv/.npm-packages"
/opt/techs/$tech/bin/npm install -g yarn@berry
fi
# Remove default config in Nginx
test -e /srv/conf/nginx.d/default.conf && rm -f /srv/conf/nginx.d/default.conf
# Same thing we do for nginx but if the file exist it's not rewritten.
if [ ! -e /srv/conf/nginx.d/app.conf ]; then
mkdir -p /srv/conf/nginx.d
if [ "$name" = "php" ]; then
cp /opt/examples/php/nginx.conf /srv/conf/nginx.d/app.conf
else
cp /opt/examples/nginx/nginx.conf /srv/conf/nginx.d/app.conf
fi
echo ".. app configuration for nginx not found, adding it - please check /srv/conf/nginx.d/app.conf and make sure it fits your code"
fi
# We load new configuration into supervisor and it's automatically started or restarted if needed
supervisorctl reread
supervisorctl update
nginx -s reload
echo "NOTE: this tool doesn't restart existing processes, if it's needed, please, do it manually"
echo
if [ ! "$TESTMODE" = "1" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;; ;;
# Services like small tools, databases or so to support the running app # Services like small tools, databases or so to support the running app
"services") "services")
if [ ! "$TESTMODE" = "1" ]; then if [ "$SERVICE" = "" ]; then
service=$(whiptail --menu "Select service to be enabled" $HEIGHT $WIDTH 6 \ service=$(whiptail --menu "Select service to be enabled" $HEIGHT $WIDTH 6 \
"memcached" " Memcached" \ "memcached" " Memcached" \
"redis" " Redis" \ "redis" " Redis" \
@ -155,42 +249,7 @@ while /bin/true; do
service=$SERVICE service=$SERVICE
fi fi
case $service in setService $service
"redis")
echo ".. adding redis into supervisor and copying config file into /srv/conf/redis.conf"
mkdir -p /srv/var/redis
cp /opt/examples/redis/supervisor.conf /srv/conf/supervisor.d/redis.conf
cp /opt/examples/redis/redis.conf /srv/conf/redis.conf
supervisorctl reread
supervisorctl update
echo "NOTE: please, check configuration file /srv/conf/redis.conf and update it if needed"
echo "NOTE: Redis server is available at localhost:6379"
echo
if [ ! "$TESTMODE" = "1" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;;
"memcached")
echo ".. adding memcached into supervisor"
cp /opt/examples/memcached/supervisor.conf /srv/conf/supervisor.d/memcached.conf
supervisorctl reread
supervisorctl update
echo "NOTE: Memcached server is available at localhost:11211"
echo
if [ ! "$TESTMODE" = "1" ]; then
read -p "Check the output and hit enter to continue"
else
exit 0
fi
;;
"*")
continue
;;
esac
;; ;;
# Simpler crontab editor # Simpler crontab editor
"cron") "cron")
@ -198,7 +257,7 @@ while /bin/true; do
crontab /srv/conf/crontab crontab /srv/conf/crontab
echo echo
if [ ! "$TESTMODE" = "1" ]; then if [ ! "$TESTMODE" = "1" -a -z "$QUICK_TECH" ]; then
read -p "Check the output and hit enter to continue" read -p "Check the output and hit enter to continue"
else else
exit 0 exit 0

View File

@ -32,23 +32,6 @@ I=$((I+1))
stop stop
############### ###############
# Node.js 12.14.1
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.14.1 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT Node.js 12.14.1 response correct"
else
echo "$I/$COUNT Node.js 12.14.1 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
# Node.js 12.16.1 # Node.js 12.16.1
run run
@ -64,23 +47,23 @@ fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# Node.js 13.12.0 # Node.js 12.18.3
run run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-13.12.0 $CONTAINER_NAME su app -c rosti > /dev/null $DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.18.3 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 3 sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null $DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$I/$COUNT Node.js 13.12.0 response correct" echo "$I/$COUNT Node.js 12.18.3 response correct"
else else
echo "$I/$COUNT Node.js 13.12.0 response incorrect" echo "$I/$COUNT Node.js 12.18.3 response incorrect"
PROBLEM=1 PROBLEM=1
fi fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# Node.js 13.7.0 # Node.js 13.7.0
run run
@ -97,24 +80,23 @@ fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# Python 3.8.1 # Node.js 14.8.0
run run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.1 $CONTAINER_NAME su app -c rosti > /dev/null $DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-14.8.0 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5 sleep 3
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null $DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep package.json > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$I/$COUNT Python 3.8.1 response correct" echo "$I/$COUNT Node.js 14.8.0 response correct"
else else
echo "$I/$COUNT Python 3.8.1 response incorrect" echo "$I/$COUNT Node.js 14.8.0 response incorrect"
PROBLEM=1 PROBLEM=1
fi fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# Python 3.8.2 # Python 3.8.2
run run
@ -131,23 +113,23 @@ fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# PHP 7.4.2 # Python 3.8.5
run run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=php-7.4.2 $CONTAINER_NAME su app -c rosti > /dev/null $DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.5 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5 sleep 5
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "PHP aplikaci" > /dev/null $DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "$I/$COUNT PHP 7.4.2 response correct" echo "$I/$COUNT Python 3.8.5 response correct"
else else
echo "$I/$COUNT PHP 7.4.2 response incorrect" echo "$I/$COUNT Python 3.8.5 response incorrect"
PROBLEM=1 PROBLEM=1
fi fi
I=$((I+1)) I=$((I+1))
stop stop
###############
# PHP 7.4.4 # PHP 7.4.4
run run
@ -165,6 +147,22 @@ fi
I=$((I+1)) I=$((I+1))
stop stop
# PHP 7.4.9
run
$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=php-7.4.9 $CONTAINER_NAME su app -c rosti > /dev/null
sleep 5
$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "PHP aplikaci" > /dev/null
if [ $? -eq 0 ]; then
echo "$I/$COUNT PHP 7.4.9 response correct"
else
echo "$I/$COUNT PHP 7.4.9 response incorrect"
PROBLEM=1
fi
I=$((I+1))
stop
############### ###############
if [ "$PROBLEM" = "0" ]; then if [ "$PROBLEM" = "0" ]; then