Docker container for Nginx with Web2py using python 3 on Ubuntu 20.04 based on onezoom/docker-nginx derived from madharjan/docker-nginx
- 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 withoutadmin
,example
andwelcome
- Bats bats-core/bats-core based test cases
Variable | Default | Example |
---|---|---|
WEB2PY_ADMIN | Pa55w0rd | |
DISABLE_UWSGI | 0 | 1 (to disable) |
INSTALL_PROJECT | 0 | 1 (to enable) |
PROJECT_GIT_REPO | https://github.com/OneZoom/OZtree | |
PROJECT_GIT_TAG | HEAD | v5.1.4 |
PROJECT_APPCONFIG_INI_PATH | /etc/appconfig.ini |
# clone project
git clone https://github.com/onezoom/docker-nginx-web2py
cd docker-nginx-web2py
# build
make
# tests
make run
make test
# clean
make clean
# prepare foldor on host for container volumes
sudo mkdir -p /opt/docker/web2py/applications/
sudo mkdir -p /opt/docker/web2py/log/
docker stop web2py
docker rm web2py
# run container
# Web2py include Admin, Example and Welcome
docker run -d \
-e WEB2PY_ADMIN=Pa55word \
-p 80:80 \
-v /opt/docker/web2py/applications:/opt/web2py/applications \
-v /opt/docker/web2py/log:/var/log/nginx \
--name web2py \
onezoom/docker-nginx-web2py:2.21.1
# run container
# Web2py Minimal
docker run -d \
-e WEB2PY_ADMIN=Pa55word \
-p 80:80 \
-v /opt/docker/web2py/applications:/opt/web2py/applications \
-v /opt/docker/web2py/log:/var/log/nginx \
--name web2py \
onezoom/docker-nginx-web2py-min:2.21.1
Note: update environment variables below as necessary
[Unit]
Description=Web2py Framework
After=docker.service
[Service]
TimeoutStartSec=0
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 onezoom/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 \
onezoom/docker-nginx-web2py:2.21.1
ExecStop=/usr/bin/docker stop -t 2 web2py
[Install]
WantedBy=multi-user.target
Variable | Default | Example |
---|---|---|
PORT | 8080 | |
VOLUME_HOME | /opt/docker | /opt/data |
NAME | ngnix | |
WEB2PY_ADMIN | Pa55w0rd | |
WEB2PY_MIN | true | false |
INSTALL_PROJECT | 0 | 1 (to enable) |
PROJECT_GIT_REPO | https://github.com/OneZoom/OZtree | |
PROJECT_GIT_TAG | HEAD | v1.0 |
docker run --rm \
-e PORT=80 \
-e VOLUME_HOME=/opt/docker \
-e VERSION=2.21.1 \
-e WEB2PY_ADMIN=Pa55w0rd \
-e WEB2PY_MIN=false \
-e INSTALL_PROJECT=1 \
-e PROJECT_GIT_REPO=https://github.com/OneZoom/OZtree \
-e PROJECT_GIT_TAG=HEAD \
onezoom/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.