From 85b9c089599989a1f69b4819dbd0201f06440966 Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Wed, 28 Apr 2021 12:29:55 +0100 Subject: [PATCH 1/4] Switch to python3 --- services/uwsgi/uwsgi.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/uwsgi/uwsgi.ini b/services/uwsgi/uwsgi.ini index 4d41cf1..e35bf0d 100644 --- a/services/uwsgi/uwsgi.ini +++ b/services/uwsgi/uwsgi.ini @@ -16,5 +16,5 @@ reload-on-rss = 192 uid = www-data gid = www-data touch-reload = /opt/web2py/routes.py -cron = 0 0 -1 -1 -1 python /opt/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o +cron = 0 0 -1 -1 -1 python3 /opt/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o no-orphans = true From a7c28b1d5ab02f7d3d619b2258be7b9c27f82981 Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Wed, 28 Apr 2021 16:53:12 +0100 Subject: [PATCH 2/4] Update to python3 for internal scripts and web2py 2.21.1 Since Xenial, on which this is based, only has python3.5, we need to use pip < 21.0 --- Changelog.md | 7 +++++++ Makefile | 2 +- README.md | 14 +++++++------- bin/web2py-setpass | 2 +- bin/web2py-systemd-unit | 2 +- scripts/install.sh | 4 ++-- services/uwsgi/uwsgi.sh | 11 ++++++----- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8c317b5..63a8c36 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +## 2.21.1 + +### Changes + +* Use python3 throughout (v3.5) +* Update to version 2.21.1 + ## 2.18.3 ### Changes diff --git a/Makefile b/Makefile index df21e2b..e001a1c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ NAME = madharjan/docker-nginx-web2py -VERSION = 2.18.3 +VERSION = 2.21.1 DEBUG ?= true diff --git a/README.md b/README.md index ba664bf..a2b27eb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Docker container for Nginx with Web2py based on [madharjan/docker-nginx](https:/ * Minimal (for production deploy) version of container `docker-nginx-web2py-min` for Web2py without `admin`, `example` and `welcome` * Bats [bats-core/bats-core](https://github.com/bats-core/bats-core) based test cases -## Nginx 1.10.3 & Web2py 2.18.3 (docker-nginx-web2py) +## Nginx 1.10.3 & Web2py 2.21.1 (docker-nginx-web2py) ### Environment @@ -60,7 +60,7 @@ docker run -d \ -v /opt/docker/web2py/applications:/opt/web2py/applications \ -v /opt/docker/web2py/log:/var/log/nginx \ --name web2py \ - madharjan/docker-nginx-web2py:2.18.5 + madharjan/docker-nginx-web2py:2.21.1 # run container # Web2py Minimal @@ -70,7 +70,7 @@ docker run -d \ -v /opt/docker/web2py/applications:/opt/web2py/applications \ -v /opt/docker/web2py/log:/var/log/nginx \ --name web2py \ - madharjan/docker-nginx-web2py-min:2.18.5 + madharjan/docker-nginx-web2py-min:2.21.1 ``` ## Systemd Unit File @@ -90,7 +90,7 @@ ExecStartPre=-/bin/mkdir -p /opt/docker/web2py/applications ExecStartPre=-/bin/mkdir -p /opt/docker/web2py/log ExecStartPre=-/usr/bin/docker stop web2py ExecStartPre=-/usr/bin/docker rm web2py -ExecStartPre=-/usr/bin/docker pull madharjan/docker-nginx-web2py:2.18.5 +ExecStartPre=-/usr/bin/docker pull madharjan/docker-nginx-web2py:2.21.1 ExecStart=/usr/bin/docker run \ -e WEB2PY_ADMIN=Pa55w0rd \ @@ -98,7 +98,7 @@ ExecStart=/usr/bin/docker run \ -v /opt/docker/web2py/applications:/opt/web2py/applications \ -v /opt/docker/web2py/log:/var/log/nginx \ --name web2py \ - madharjan/docker-nginx-web2py:2.18.5 + madharjan/docker-nginx-web2py:2.21.1 ExecStop=/usr/bin/docker stop -t 2 web2py @@ -127,13 +127,13 @@ WantedBy=multi-user.target docker run --rm \ -e PORT=80 \ -e VOLUME_HOME=/opt/docker \ - -e VERSION=2.18.5 \ + -e VERSION=2.21.1 \ -e WEB2PY_ADMIN=Pa55w0rd \ -e WEB2PY_MIN=false \ -e INSTALL_PROJECT=1 \ -e PROJECT_GIT_REPO=https://github.com/madharjan/web2py-contest.git \ -e PROJECT_GIT_TAG=HEAD \ - madharjan/docker-nginx-web2py-min:2.18.5 \ + madharjan/docker-nginx-web2py-min:2.21.1 \ web2py-systemd-unit | \ sudo tee /etc/systemd/system/web2py.service diff --git a/bin/web2py-setpass b/bin/web2py-setpass index f4d32b3..83b79c7 100644 --- a/bin/web2py-setpass +++ b/bin/web2py-setpass @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys from gluon.main import save_password; diff --git a/bin/web2py-systemd-unit b/bin/web2py-systemd-unit index 9a3d582..4dfb8a1 100755 --- a/bin/web2py-systemd-unit +++ b/bin/web2py-systemd-unit @@ -6,7 +6,7 @@ if [ "${DEBUG}" = true ]; then set -x fi -VERSION=2.18.3 +VERSION=2.21.1 DEF_PORT=80 DEF_VOLUME_HOME=/opt/docker diff --git a/scripts/install.sh b/scripts/install.sh index 84c3995..6584064 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -23,14 +23,14 @@ pip install gitpython ## Install Web2py mkdir -p /opt/tmp cd /opt/tmp -git clone https://github.com/web2py/web2py.git --depth 1 --branch R-2.18.3 --single-branch web2py +git clone https://github.com/web2py/web2py.git --depth 1 --branch v2.21.1 --single-branch web2py cd web2py git submodule update --init --recursive cd ../../ if [ "${WEB2PY_MIN}" == true ]; then cd tmp/web2py - python scripts/make_min_web2py.py ../../tmp/web2py-min + python3 scripts/make_min_web2py.py ../../tmp/web2py-min mv ../../tmp/web2py-min ../../web2py cd ../../ else diff --git a/services/uwsgi/uwsgi.sh b/services/uwsgi/uwsgi.sh index 0e27619..c59606a 100755 --- a/services/uwsgi/uwsgi.sh +++ b/services/uwsgi/uwsgi.sh @@ -9,17 +9,18 @@ fi UWSGI_BUILD_PATH=/build/services/uwsgi -## Install Nginx. +## Install uwsgi. apt-get install -y --no-install-recommends \ build-essential \ libxml2-dev \ - python-dev \ - python-pip \ + python3-dev \ + python3-pip \ unzip \ rsync -pip install setuptools --upgrade -PIPPATH=`which pip` +PIPPATH=`which pip3` +$PIPPATH install --upgrade "pip < 21.0" +$PIPPATH install setuptools --upgrade $PIPPATH install wheel $PIPPATH install --upgrade uwsgi From d214f6dc5547ca95b747b7b2a395f551d5db6f2b Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Thu, 29 Apr 2021 13:34:01 +0100 Subject: [PATCH 3/4] Allow an appconfig.ini file to be set --- README.md | 27 ++++++++++++++++++--------- bin/web2py-systemd-unit | 2 ++ services/16-project.sh | 5 ++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a2b27eb..0e87138 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Docker container for Nginx with Web2py based on [madharjan/docker-nginx](https:/ ## Features * Environment variables to set admin password +* User-provided appconfig.ini file can be specified * Minimal (for production deploy) version of container `docker-nginx-web2py-min` for Web2py without `admin`, `example` and `welcome` * Bats [bats-core/bats-core](https://github.com/bats-core/bats-core) based test cases @@ -15,14 +16,15 @@ Docker container for Nginx with Web2py based on [madharjan/docker-nginx](https:/ ### Environment -| Variable | Default | Example | -|----------------------|---------|--------------------------------------------------------------------------------------------| -| WEB2PY_ADMIN | | Pa55w0rd | -| DISABLE_UWSGI | 0 | 1 (to disable) | -| | | | -| INSTALL_PROJECT | 0 | 1 (to enable) | -| PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) | -| PROJECT_GIT_TAG | HEAD | v5.1.4 | +| Variable | Default | Example | +|---------------------------|---------|--------------------------------------------------------------------------------------------| +| WEB2PY_ADMIN | | Pa55w0rd | +| DISABLE_UWSGI | 0 | 1 (to disable) | +| | | | +| INSTALL_PROJECT | 0 | 1 (to enable) | +| PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) | +| PROJECT_GIT_TAG | HEAD | v5.1.4 | +| PROJECT_APPCONFIG_INI_PATH| | /etc/appconfig.ini | ## Build @@ -121,7 +123,7 @@ WantedBy=multi-user.target | PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) | | PROJECT_GIT_TAG | HEAD | v1.0 | -### With deploy web projects +### To deploy web projects ```bash docker run --rm \ @@ -140,3 +142,10 @@ docker run --rm \ sudo systemctl enable web2py sudo systemctl start web2py ``` + +note that some projects may require an bespoke appconfig.ini file, e.g. to specify +a database to be used with this docker instance. This can be done by mounting +a fine in your docker image at (e.g.) /etc/appconfig.ini, then setting +PROJECT_APPCONFIG_INI_PATH to this file path, from where it will be moved into +the `private` directory of your web2py project, overwriting any existing +appconfig.ini file in there. \ No newline at end of file diff --git a/bin/web2py-systemd-unit b/bin/web2py-systemd-unit index 4dfb8a1..e924d60 100755 --- a/bin/web2py-systemd-unit +++ b/bin/web2py-systemd-unit @@ -13,6 +13,7 @@ DEF_VOLUME_HOME=/opt/docker DEF_NAME=web2py DEF_INSTALL_PROJECT=0 DEF_PROJECT_GIT_REPO= +DEF_PROJECT_APPCONFIG_INI_PATH= DEF_PROJECT_GIT_TAG= DEF_WEB2PY_ADMIN= @@ -24,6 +25,7 @@ NAME=${NAME:-$DEF_NAME} INSTALL_PROJECT=${INSTALL_PROJECT:-$DEF_INSTALL_PROJECT} PROJECT_GIT_REPO=${PROJECT_GIT_REPO:-$DEF_PROJECT_GIT_REPO} +PROJECT_APPCONFIG_INI_PATH=${PROJECT_APPCONFIG_INI_PATH:-$DEF_PROJECT_APPCONFIG_INI_PATH} PROJECT_GIT_TAG=${PROJECT_GIT_TAG:-$DEF_PROJECT_GIT_TAG} WEB2PY_ADMIN=${WEB2PY_ADMIN:-$DEF_WEB2PY_ADMIN} diff --git a/services/16-project.sh b/services/16-project.sh index d3b65d8..9c17424 100644 --- a/services/16-project.sh +++ b/services/16-project.sh @@ -16,7 +16,10 @@ if [ ! "${INSTALL_PROJECT}" -eq 0 ]; then mkdir -p /opt/web2py/applications/${FOLDER} rsync -avh --remove-source-files --delete /var/www/html/* /opt/web2py/applications/${FOLDER}/ find . -type d -empty -delete - + # If an alterative appconfig.ini file has been provided via an env var, use that + if [ -n "${PROJECT_APPCONFIG_INI_PATH}" ]; then + cp "${PROJECT_APPCONFIG_INI_PATH}" "/opt/web2py/applications/${FOLDER}/private/appconfig.ini" + fi fi fi From aebce0beaa29e4ea3e15f137595f692c84b5193a Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Thu, 29 Apr 2021 13:40:39 +0100 Subject: [PATCH 4/4] install python3 version of gitpython --- scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 6584064..2728659 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -18,7 +18,7 @@ cp ${NGINX_CONFIG_PATH}/default-web2py.conf /config/etc/nginx-web2py/conf.d/defa /build/services/uwsgi/uwsgi.sh apt-get install -y --no-install-recommends git-core -pip install gitpython +pip3 install gitpython ## Install Web2py mkdir -p /opt/tmp