Skip to content

Commit d214f6d

Browse files
committed
Allow an appconfig.ini file to be set
1 parent a7c28b1 commit d214f6d

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ Docker container for Nginx with Web2py based on [madharjan/docker-nginx](https:/
88
## Features
99

1010
* Environment variables to set admin password
11+
* User-provided appconfig.ini file can be specified
1112
* Minimal (for production deploy) version of container `docker-nginx-web2py-min` for Web2py without `admin`, `example` and `welcome`
1213
* Bats [bats-core/bats-core](https://github.com/bats-core/bats-core) based test cases
1314

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

1617
### Environment
1718

18-
| Variable | Default | Example |
19-
|----------------------|---------|--------------------------------------------------------------------------------------------|
20-
| WEB2PY_ADMIN | | Pa55w0rd |
21-
| DISABLE_UWSGI | 0 | 1 (to disable) |
22-
| | | |
23-
| INSTALL_PROJECT | 0 | 1 (to enable) |
24-
| PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) |
25-
| PROJECT_GIT_TAG | HEAD | v5.1.4 |
19+
| Variable | Default | Example |
20+
|---------------------------|---------|--------------------------------------------------------------------------------------------|
21+
| WEB2PY_ADMIN | | Pa55w0rd |
22+
| DISABLE_UWSGI | 0 | 1 (to disable) |
23+
| | | |
24+
| INSTALL_PROJECT | 0 | 1 (to enable) |
25+
| PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) |
26+
| PROJECT_GIT_TAG | HEAD | v5.1.4 |
27+
| PROJECT_APPCONFIG_INI_PATH| | /etc/appconfig.ini |
2628

2729
## Build
2830

@@ -121,7 +123,7 @@ WantedBy=multi-user.target
121123
| PROJECT_GIT_REPO | | [https://github.com/madharjan/web2py-contest](https://github.com/madharjan/web2py-contest) |
122124
| PROJECT_GIT_TAG | HEAD | v1.0 |
123125

124-
### With deploy web projects
126+
### To deploy web projects
125127

126128
```bash
127129
docker run --rm \
@@ -140,3 +142,10 @@ docker run --rm \
140142
sudo systemctl enable web2py
141143
sudo systemctl start web2py
142144
```
145+
146+
note that some projects may require an bespoke appconfig.ini file, e.g. to specify
147+
a database to be used with this docker instance. This can be done by mounting
148+
a fine in your docker image at (e.g.) /etc/appconfig.ini, then setting
149+
PROJECT_APPCONFIG_INI_PATH to this file path, from where it will be moved into
150+
the `private` directory of your web2py project, overwriting any existing
151+
appconfig.ini file in there.

bin/web2py-systemd-unit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ DEF_VOLUME_HOME=/opt/docker
1313
DEF_NAME=web2py
1414
DEF_INSTALL_PROJECT=0
1515
DEF_PROJECT_GIT_REPO=
16+
DEF_PROJECT_APPCONFIG_INI_PATH=
1617
DEF_PROJECT_GIT_TAG=
1718

1819
DEF_WEB2PY_ADMIN=
@@ -24,6 +25,7 @@ NAME=${NAME:-$DEF_NAME}
2425

2526
INSTALL_PROJECT=${INSTALL_PROJECT:-$DEF_INSTALL_PROJECT}
2627
PROJECT_GIT_REPO=${PROJECT_GIT_REPO:-$DEF_PROJECT_GIT_REPO}
28+
PROJECT_APPCONFIG_INI_PATH=${PROJECT_APPCONFIG_INI_PATH:-$DEF_PROJECT_APPCONFIG_INI_PATH}
2729
PROJECT_GIT_TAG=${PROJECT_GIT_TAG:-$DEF_PROJECT_GIT_TAG}
2830

2931
WEB2PY_ADMIN=${WEB2PY_ADMIN:-$DEF_WEB2PY_ADMIN}

services/16-project.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ if [ ! "${INSTALL_PROJECT}" -eq 0 ]; then
1616
mkdir -p /opt/web2py/applications/${FOLDER}
1717
rsync -avh --remove-source-files --delete /var/www/html/* /opt/web2py/applications/${FOLDER}/
1818
find . -type d -empty -delete
19-
19+
# If an alterative appconfig.ini file has been provided via an env var, use that
20+
if [ -n "${PROJECT_APPCONFIG_INI_PATH}" ]; then
21+
cp "${PROJECT_APPCONFIG_INI_PATH}" "/opt/web2py/applications/${FOLDER}/private/appconfig.ini"
22+
fi
2023
fi
2124

2225
fi

0 commit comments

Comments
 (0)