Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.21.1

### Changes

* Use python3 throughout (v3.5)
* Update to version 2.21.1

## 2.18.3

### Changes
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

NAME = madharjan/docker-nginx-web2py
VERSION = 2.18.3
VERSION = 2.21.1

DEBUG ?= true

Expand Down
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ 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

## Nginx 1.10.3 & Web2py 2.18.3 (docker-nginx-web2py)
## Nginx 1.10.3 & Web2py 2.21.1 (docker-nginx-web2py)

### 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

Expand Down Expand Up @@ -60,7 +62,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
Expand All @@ -70,7 +72,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
Expand All @@ -90,15 +92,15 @@ 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 \
-p 80:80 \
-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

Expand All @@ -121,22 +123,29 @@ 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 \
-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

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.
2 changes: 1 addition & 1 deletion bin/web2py-setpass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import sys
from gluon.main import save_password;
Expand Down
4 changes: 3 additions & 1 deletion bin/web2py-systemd-unit
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ if [ "${DEBUG}" = true ]; then
set -x
fi

VERSION=2.18.3
VERSION=2.21.1

DEF_PORT=80
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=
Expand All @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ 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
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
Expand Down
5 changes: 4 additions & 1 deletion services/16-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion services/uwsgi/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions services/uwsgi/uwsgi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down