From d2333b2b3a8e616c27b4deab8cc13b4e860706cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Fri, 3 Feb 2023 17:46:51 +0100 Subject: [PATCH] Version 2023.2-1, new Deno and Node, PHP fix, admin versions generator --- Dockerfile | 4 + Makefile | 11 ++- generate_versions.py | 38 ++++++++++ rosti.tmpl.sh | 7 +- tests.sh | 176 ------------------------------------------- 5 files changed, 54 insertions(+), 182 deletions(-) create mode 100644 generate_versions.py delete mode 100755 tests.sh diff --git a/Dockerfile b/Dockerfile index d185fd5..3992fd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,9 @@ ADD build_node.sh /usr/local/bin/build_node.sh RUN build_node.sh 16.19.0 RUN build_node.sh 17.9.1 RUN build_node.sh 18.12.1 +RUN build_node.sh 18.14.0 RUN build_node.sh 19.3.0 +RUN build_node.sh 19.6.0 ## Python WORKDIR /usr/src @@ -63,6 +65,7 @@ ADD build_php8.sh /usr/local/bin/build_php8.sh # 2022/12 RUN build_php8.sh 8.1.13 RUN build_php8.sh 8.2.0 +RUN build_php8.sh 8.2.1 ## Ruby WORKDIR /usr/src @@ -75,6 +78,7 @@ RUN build_ruby.sh 3.2.0 ADD build_deno.sh /usr/local/bin/build_deno.sh # 2022/12 RUN build_deno.sh 1.29.1 +RUN build_deno.sh 1.30.1 ############# diff --git a/Makefile b/Makefile index c8c5ef0..8a7e1dd 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,26 @@ REPO=harbor.hq.rosti.cz/rosti/runtime DOCKER=docker -VERSION=2023.01-1 +VERSION=2023.02-1 +BASEIMAGE=debian:11 all: build build: - $(DOCKER) pull debian:11 + $(DOCKER) pull ${BASEIMAGE} $(DOCKER) build -t ${REPO}:dev . $(DOCKER) tag ${REPO}:dev ${REPO}:$(VERSION) + @echo "JSON for admin:" + python generate_versions.py test: DOCKER=$(DOCKER) bash ./tests2.sh ${REPO}:$(VERSION) squashed: - $(DOCKER) pull debian:11 + $(DOCKER) pull ${BASEIMAGE} $(DOCKER) build --squash -t ${REPO}:dev-squashed . $(DOCKER) tag ${REPO}:dev-squashed ${REPO}:$(VERSION) + @echo "JSON for admin:" + python generate_versions.py push: squashed $(DOCKER) push ${REPO}:$(VERSION) diff --git a/generate_versions.py b/generate_versions.py new file mode 100644 index 0000000..de20b90 --- /dev/null +++ b/generate_versions.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import json +import os +import subprocess + +output = { + "techs": {}, + "system": { + "distro": "debian", + "version": "11.6", + } +} + +image = "" +with open("Dockerfile") as f: + lines = f.readlines() + for line in lines: + if line.startswith("FROM debian:"): + image = line.split(" ")[1].strip() + continue + if line.startswith("RUN build_"): + parts = line.split(" ") + name = parts[1].replace("build_", "").replace(".sh", "") + if name.startswith("php"): + name = "php" + version = line.split(" ")[2].strip() + if name not in output["techs"]: + output["techs"][name] = { + "versions": [], + } + output["techs"][name]["versions"].append(version) + +# os.system(f"docker pull {image}") +system_version = subprocess.check_output(f"podman run --rm {image} cat /etc/debian_version", shell=True) +output["system"]["version"] = system_version.strip().decode() + +print(json.dumps(output, indent=4)) diff --git a/rosti.tmpl.sh b/rosti.tmpl.sh index f9c79d6..51e90ce 100755 --- a/rosti.tmpl.sh +++ b/rosti.tmpl.sh @@ -4,10 +4,11 @@ # DEFAULT VERSIONS VERSION_PYTHON=3.11.1 -VERSION_PHP=8.2.0 -VERSION_NODE=18.12.1 +VERSION_PHP=8.2.1 +VERSION_NODE=18.14.0 VERSION_RUBY=3.2.0 VERSION_DENO=1.29.1 +VERSION_DENO=1.30.1 WIDTH=180 HEIGHT=25 @@ -85,7 +86,7 @@ function setTech() { # 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 + rm -f /srv/app/php-fpm.conf /srv/app/pool_app.conf /srv/app/php.ini fi # Node specific stuff diff --git a/tests.sh b/tests.sh deleted file mode 100755 index f92e94b..0000000 --- a/tests.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash - -if [ -z "$DOCKER" ]; then - DOCKER=docker -fi - -CONTAINER_NAME=runtime-test -I=1 -COUNT=9 -PROBLEM=0 - -function run() { - $DOCKER run -d --rm --name $CONTAINER_NAME rosti/runtime:dev > /dev/null - sleep 5 -} -function stop() { - $DOCKER stop $CONTAINER_NAME > /dev/null - sleep 5 -} - -# Default page -run -$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "Roští.cz" > /dev/null -if [ $? -eq 0 ]; then - echo "$I/$COUNT default response correct" -else - echo "$I/$COUNT default response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop -############### - -# Node.js 12.16.1 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.16.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.16.1 response correct" -else - echo "$I/$COUNT Node.js 12.16.1 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop - -# Node.js 12.18.3 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-12.18.3 $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.18.3 response correct" -else - echo "$I/$COUNT Node.js 12.18.3 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop -############### - -# Node.js 13.7.0 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-13.7.0 $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 13.7.0 response correct" -else - echo "$I/$COUNT Node.js 13.7.0 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop - -# Node.js 14.8.0 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=node-14.8.0 $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 14.8.0 response correct" -else - echo "$I/$COUNT Node.js 14.8.0 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop -############### - -# Python 3.8.2 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.2 $CONTAINER_NAME su app -c rosti > /dev/null -sleep 5 -$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null -if [ $? -eq 0 ]; then - echo "$I/$COUNT Python 3.8.2 response correct" -else - echo "$I/$COUNT Python 3.8.2 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop - -# Python 3.8.5 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=python-3.8.5 $CONTAINER_NAME su app -c rosti > /dev/null -sleep 5 -$DOCKER exec $CONTAINER_NAME curl http://localhost:8000 | grep "app.py" > /dev/null -if [ $? -eq 0 ]; then - echo "$I/$COUNT Python 3.8.5 response correct" -else - echo "$I/$COUNT Python 3.8.5 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -stop -############### - -# PHP 7.4.4 -run - -$DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=php-7.4.4 $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.4 response correct" -else - echo "$I/$COUNT PHP 7.4.4 response incorrect" - PROBLEM=1 -fi - -I=$((I+1)) -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 - echo - echo "All OK" - exit 0 -else - echo - echo "Problem found" - exit 1 -fi