Sign inSign up

onezoom/docker-nginx-web2py

By onezoom

•Updated over 1 year ago

Docker container for Nginx with Web2py using python3 / Ubuntu 20.04 based on madharjan/docker-nginx

Image
0

981

onezoom/docker-nginx-web2py repository overview

⁠docker-nginx-web2py

Build Status Layers

Docker container for Nginx with Web2py using python 3 on Ubuntu 20.04 based on onezoom/docker-nginx⁠ derived from madharjan/docker-nginx⁠

⁠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⁠ based test cases

⁠Nginx 1.18.0 & Web2py 2.21.1 (docker-nginx-web2py)

⁠Environment
VariableDefaultExample
WEB2PY_ADMINPa55w0rd
DISABLE_UWSGI01 (to disable)
INSTALL_PROJECT01 (to enable)
PROJECT_GIT_REPOhttps://github.com/OneZoom/OZtree⁠
PROJECT_GIT_TAGHEADv5.1.4
PROJECT_APPCONFIG_INI_PATH/etc/appconfig.ini

⁠Build

# 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

⁠Run

# 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

⁠Systemd Unit File

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

⁠Generate Systemd Unit File

VariableDefaultExample
PORT8080
VOLUME_HOME/opt/docker/opt/data
NAMEngnix
WEB2PY_ADMINPa55w0rd
WEB2PY_MINtruefalse
INSTALL_PROJECT01 (to enable)
PROJECT_GIT_REPOhttps://github.com/OneZoom/OZtree⁠
PROJECT_GIT_TAGHEADv1.0
⁠To deploy web projects
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.

Tag summary

Content type

Image

Digest

sha256:ada4e23c4…

Size

291.1 MB

Last updated

over 1 year ago

docker pull onezoom/docker-nginx-web2py