diff --git a/Dockerfile b/Dockerfile index f4c9c90..b725165 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,24 +4,28 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wget gpg +RUN echo "deb http://deb.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list && \ + echo "deb http://security.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list && \ + echo "deb http://deb.debian.org/debian buster-updates main contrib non-free" >> /etc/apt/sources.list + RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN DEBIAN_FRONTEND=noninteractive apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales libffi-dev \ +RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales libffi-dev \ libssl-dev default-libmysqlclient-dev ca-certificates libpq-dev libjpeg62 libjpeg-dev \ libpng-dev libpng-dev build-essential git mercurial build-essential \ libbz2-dev libsqlite3-dev libreadline-dev zlib1g-dev libncurses5-dev \ -libssl-dev libgdbm-dev libgd-dev cron git mercurial subversion vim nano mc htop procps \ -subversion dropbear gettext wget redis-server memcached supervisor curl ssh \ +libgdbm-dev libgd-dev cron git subversion vim nano mc htop procps \ +dropbear gettext wget redis-server memcached supervisor curl ssh \ mariadb-client postgresql-client-12 postgresql-12-postgis-3-scripts bind9-host dnsutils nginx \ libxml2-dev libxslt1-dev openssh-sftp-server links2 lynx \ -imagemagick libmagickwand-dev ncdu \ -libcurl4-openssl-dev python3 python3-pip python3-virtualenv \ +imagemagick libmagick++-6.q16-dev libmagick++-6.q16hdri-dev libmagickwand-dev ncdu libsodium-dev \ +python3 python3-pip python3-virtualenv \ libcurl4-openssl-dev python-dev libproj-dev gdal-bin libmemcached-dev swig mutt \ -imagemagick ffmpeg libyaml-dev libc-client2007e-dev libonig-dev libkrb5-dev dialog \ -whiptail tmux rsync nmap libzip-dev - +ffmpeg libyaml-dev libc-client2007e-dev libonig-dev libkrb5-dev dialog \ +whiptail tmux rsync nmap libzip-dev libfreetype6-dev \ +jpegoptim optipng pngquant gifsicle webp # User requirement (svgo not available) + WORKDIR /srv RUN useradd -d /srv app -s /bin/bash @@ -44,40 +48,45 @@ ENV TERM xterm WORKDIR /usr/src ADD build_node.sh /usr/local/bin/build_node.sh -# 2020/01 -RUN build_node.sh 13.12.0 -RUN build_node.sh 14.8.0 -# 2020/01 -RUN build_node.sh 12.16.1 -RUN build_node.sh 12.18.3 +# 2021/02 +RUN build_node.sh 15.8.0 +RUN build_node.sh 14.15.4 ## Python WORKDIR /usr/src ADD build_python.sh /usr/local/bin/build_python.sh # 2020/01 -RUN build_python.sh 3.8.2 RUN build_python.sh 3.8.5 +# 2020/12 +RUN build_python.sh 3.9.1 ## PHP WORKDIR /usr/src ADD build_php.sh /usr/local/bin/build_php.sh # 2020/01 -RUN build_php.sh 7.4.4 RUN build_php.sh 7.4.9 +# 2021/02 +RUN build_php.sh 7.4.15 -## Roští script +## Ruby +WORKDIR /usr/src +ADD build_ruby.sh /usr/local/bin/build_ruby.sh +# 2020/11 +RUN build_ruby.sh 2.7.2 +# 2020/12 +RUN build_ruby.sh 3.0.0 -ADD rosti.sh /usr/local/bin/rosti +## Deno +ADD build_deno.sh /usr/local/bin/build_deno.sh +# 2021/02 +RUN build_deno.sh 1.7.2 ############# ## Support tools and miscellaneous stuff -ADD /start.sh /start.sh -RUN chmod 755 /start.sh - RUN rm -f /etc/cron.d/* /etc/cron.daily/* /etc/cron.hourly/* /etc/cron.monthly/* /etc/cron.weekly/* ADD /scripts/enable_redis.sh /usr/local/bin/enable-redis @@ -100,6 +109,19 @@ RUN chown app:app /var/log/nginx -R RUN chown app:app /home -R +# Start script + +ADD /start.sh /start.sh +RUN chmod 755 /start.sh + +## Roští script + +RUN apt-get install -y fish +ADD ./gen_rosti.fish /usr/local/bin/ +ADD ./rosti.sh.tmp /usr/src/ +ADD ./Dockerfile /usr/src/ +RUN cd /usr/src && /usr/local/bin/gen_rosti.fish > /usr/local/bin/rosti && chmod 755 /usr/local/bin/rosti + ## Cleaning RUN apt-get clean && rm -rf /usr/src/* diff --git a/Makefile b/Makefile index 6b8201a..8141b96 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ DOCKER=docker -VERSION=2020.09-2 +VERSION=2021.02-1 all: build diff --git a/build_deno.sh b/build_deno.sh new file mode 100755 index 0000000..6f89592 --- /dev/null +++ b/build_deno.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +mkdir -p /opt/techs + +VERSION=$1 + +cd /usr/src + +wget https://github.com/denoland/deno/releases/download/v$VERSION/deno-x86_64-unknown-linux-gnu.zip +unzip deno-x86_64-unknown-linux-gnu.zip + +mkdir -p /opt/techs/deno-$VERSION/bin +mv deno /opt/techs/deno-$VERSION/bin/deno diff --git a/build_php.sh b/build_php.sh index 44eab0e..8d83de0 100755 --- a/build_php.sh +++ b/build_php.sh @@ -21,7 +21,7 @@ cd php-$VERSION --sbindir=/opt/techs/php-$VERSION/bin \ --with-pdo-pgsql \ --with-zlib-dir \ - --with-freetype-dir \ + --with-freetype \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ @@ -47,8 +47,8 @@ cd php-$VERSION --with-pcre-regex \ --with-mysql \ --with-pdo-mysql \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ + --with-jpeg \ + --with-png-dir \ --enable-gd-native-ttf \ --with-openssl \ --with-fpm-user=app\ @@ -61,6 +61,7 @@ cd php-$VERSION --enable-opcache \ --with-imap \ --with-imap-ssl \ + --with-sodium \ --with-kerberos \ --with-soapclient \ --with-pear @@ -75,5 +76,7 @@ curl -s https://getcomposer.org/installer | ./php -d allow_url_fopen=On cd - echo "no" | /opt/techs/php-$VERSION/bin/pecl install redis +echo "no" | /opt/techs/php-$VERSION/bin/pecl install imagick echo "extension=redis.so" > /opt/techs/php-$VERSION/etc/conf.d/extensions.ini +echo "extension=imagick.so" >> /opt/techs/php-$VERSION/etc/conf.d/extensions.ini diff --git a/build_ruby.sh b/build_ruby.sh new file mode 100755 index 0000000..5244d78 --- /dev/null +++ b/build_ruby.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +VERSION=$1 + +mkdir -p /opt/techs + +cd /usr/src + +SUBVERSION=`echo $VERSION | cut -d "." -f 1`.`echo $VERSION | cut -d "." -f 2` + +wget https://cache.ruby-lang.org/pub/ruby/$SUBVERSION/ruby-$VERSION.tar.gz +tar xf ruby-$VERSION.tar.gz +rm ruby-$VERSION.tar.gz + +cd ruby-$VERSION +./configure --prefix=/opt/techs/ruby-$VERSION +make -j +make install diff --git a/examples/deno/app.js b/examples/deno/app.js new file mode 100644 index 0000000..783f4b0 --- /dev/null +++ b/examples/deno/app.js @@ -0,0 +1,74 @@ +import { serve } from "https://deno.land/std@0.86.0/http/server.ts"; + +const server = serve({ hostname: "0.0.0.0", port: 8080 }); +console.log(`HTTP webserver running. Access it at: http://localhost:8080/`); + +for await (const request of server) { + let bodyContent = ` + + + + + + Roští.cz + + + +
+
+ +
+
+
+

Kde to jsem?

+

+

Na Roští.cz a prostředí pro vaši aplikaci je připraveno.

+

Nyní můžete obsah adresáře /srv/app vymazat a nahradit ho svoji aplikací. Pokud jste u nás poprvé, tak pomůže naše dokumentace.

+

HTTP server vaší aplikace spusťte na portu 8080. Na jiném nebude fungovat.

+
+

V případě problémů se prosím obraťte na technickou podporu nebo na dokumentaci.

+

Tým Roští.cz | @rosti_cz

+
+
+ + + `; + + request.respond({ status: 200, body: bodyContent }); +} diff --git a/examples/deno/supervisor.conf b/examples/deno/supervisor.conf new file mode 100644 index 0000000..4b5e851 --- /dev/null +++ b/examples/deno/supervisor.conf @@ -0,0 +1,14 @@ +[program:app] +command=/srv/bin/primary_tech/deno run --allow-net app.js +environment=PATH="/srv/bin/primary_tech:/usr/local/bin:/usr/bin:/bin:/srv/.npm-packages/bin" +stopasgroup=true +directory=/srv/app +process_name=app +autostart=true +autorestart=true +stdout_logfile=/srv/log/deno.log +stdout_logfile_maxbytes=2MB +stdout_logfile_backups=5 +stdout_capture_maxbytes=2MB +stdout_events_enabled=false +redirect_stderr=true diff --git a/examples/ruby/app.rb b/examples/ruby/app.rb new file mode 100644 index 0000000..81afed5 --- /dev/null +++ b/examples/ruby/app.rb @@ -0,0 +1,81 @@ +# http_server.rb +require 'socket' +server = TCPServer.new 8080 + +while session = server.accept + request = session.gets + puts request + + session.print "HTTP/1.1 200\r\n" # 1 + session.print "Content-Type: text/html\r\n" # 2 + session.print "\r\n" # 3 + session.print <<-EOF + + + + + + + Roští.cz + + + +
+
+ +
+
+
+

Kde to jsem?

+

+

Na Roští.cz a prostředí pro vaši aplikaci je připraveno.

+

Nyní můžete obsah adresáře /srv/app vymazat a nahradit ho svoji aplikací. Pokud jste u nás poprvé, tak pomůže naše dokumentace.

+

HTTP server vaší aplikace spusťte na portu 8080. Na jiném nebude fungovat.

+
+

V případě problémů se prosím obraťte na technickou podporu nebo na dokumentaci.

+

Tým Roští.cz | @rosti_cz

+
+
+ + + + EOF + + session.close +end diff --git a/examples/ruby/supervisor.conf b/examples/ruby/supervisor.conf new file mode 100644 index 0000000..0c0511a --- /dev/null +++ b/examples/ruby/supervisor.conf @@ -0,0 +1,14 @@ +[program:app] +command=/srv/bin/primary_tech/ruby app.rb +environment=PATH="/srv/bin/primary_tech:/usr/local/bin:/usr/bin:/bin:/srv/.npm-packages/bin" +stopasgroup=true +directory=/srv/app +process_name=app +autostart=true +autorestart=true +stdout_logfile=/srv/log/ruby.log +stdout_logfile_maxbytes=2MB +stdout_logfile_backups=5 +stdout_capture_maxbytes=2MB +stdout_events_enabled=false +redirect_stderr=true diff --git a/gen_rosti.fish b/gen_rosti.fish new file mode 100755 index 0000000..779f97c --- /dev/null +++ b/gen_rosti.fish @@ -0,0 +1,41 @@ +#!/usr/bin/fish + +set TECHS_FILE /tmp/techs.txt + +echo -n > $TECHS_FILE + +for line in (cat Dockerfile | grep "RUN build_") + set VERSION (echo $line | cut -d " " -f 3) + set TECH_SCRIPT (echo $line | cut -d " " -f 2) + + switch $TECH_SCRIPT + case "build_php.sh" + set TECH php + set TECH_VERBOSE PHP + case "build_python.sh" + set TECH python + set TECH_VERBOSE Python + case "build_node.sh" + set TECH node + set TECH_VERBOSE Node + case "build_ruby.sh" + set TECH ruby + set TECH_VERBOSE Ruby + case "build_deno.sh" + set TECH deno + set TECH_VERBOSE Deno + case '*' + set TECH unknown + end + + echo " \"$TECH-$VERSION\" \" $TECH_VERBOSE $VERSION\" \\" >> $TECHS_FILE +end + +cat rosti.sh.tmp | while read -l line + if [ "$line" = "{{TECHS}}" ] + cat $TECHS_FILE + else + echo $line + end + +end diff --git a/rosti.sh b/rosti.sh.tmp similarity index 93% rename from rosti.sh rename to rosti.sh.tmp index 53af146..a9bc29b 100755 --- a/rosti.sh +++ b/rosti.sh.tmp @@ -28,7 +28,7 @@ function setTech() { tech=$1 # Activation of primary tech bin directory - test ! -e $PRIMARYDIR || unlink $PRIMARYDIR + test ! -e $PRIMARYDIR || $TECHDIR/$tech/bin ln -s $TECHDIR/$tech/bin $PRIMARYDIR # Parse name of the tech - like python or node @@ -163,19 +163,31 @@ function quickTech() { case $TECH in "python") if [ -z "$VERSION" ]; then - VERSION=3.8.5 + VERSION=3.9.1 fi setTech $TECH-$VERSION ;; "php") if [ -z "$VERSION" ]; then - VERSION=7.4.9 + VERSION=7.4.15 fi setTech $TECH-$VERSION ;; "node") if [ -z "$VERSION" ]; then - VERSION=14.8.0 + VERSION=14.15.4 + fi + setTech $TECH-$VERSION + ;; + "ruby") + if [ -z "$VERSION" ]; then + VERSION=3.0.0 + fi + setTech $TECH-$VERSION + ;; + "deno") + if [ -z "$VERSION" ]; then + VERSION=1.7.2 fi setTech $TECH-$VERSION ;; @@ -201,7 +213,7 @@ fi while /bin/true; do if [ "$MENUITEM" = "" ]; then - menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 6 \ + menuitem=$(whiptail --menu "Choose what to do" $HEIGHT $WIDTH 10 \ "tech" " Activaton of primary tech" \ "services" " Enable additional services (Redis, Memcached, ..)" \ "cron" " Update crontab" \ @@ -216,15 +228,8 @@ while /bin/true; do # Only one tech can be enabled same time but it's possible to use any of them from /opt/techs "tech") if [ "$TECH" = "" ]; then - tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 6 \ - "python-3.8.2" " Python 3.8.2" \ - "python-3.8.5" " Python 3.8.5" \ - "node-13.12.0" " Node 13.12.0" \ - "node-14.8.0" " Node 14.8.0" \ - "node-12.16.1" " Node 12.16.1" \ - "node-12.18.3" " Node 12.18.3" \ - "php-7.4.4" " PHP 7.4.4" \ - "php-7.4.9" " PHP 7.4.9" \ + tech=$(whiptail --menu "Select tech" $HEIGHT $WIDTH 10 \ +{{TECHS}} "back" " Go back" \ 3>&1 1>&2 2>&3) else diff --git a/start.sh b/start.sh index 664bacb..e1c86c9 100755 --- a/start.sh +++ b/start.sh @@ -122,6 +122,12 @@ if [ -e /srv/app/init.sh ]; then su app -c /srv/app/init.sh fi +# Custom /etc/ssl/openssl.cnf +if [ -e /srv/conf/openssl.cnf ]; then + rm /etc/ssl/openssl.cnf + cp /srv/conf/openssl.cnf /etc/ssl/openssl.cnf +fi + #################### # Default Nginx page ####################