Skip to content

Commit e6ea76e

Browse files
committed
Allow users to pass custom flags to commands
resolves #1
1 parent 39dd4c9 commit e6ea76e

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

README.md

+43-29
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ For this container the latest version of gunicorn is always used, and the tags r
77

88
<!--ts-->
99
* [python-gunicorn-uvicorn](#python-gunicorn-uvicorn)
10-
* [Benefits](#benefits)
11-
* [Multi Architecture Builds](#multi-architecture-builds)
12-
* [Small Images via Multi Stage Builds](#small-images-via-multi-stage-builds)
13-
* [No Rate Limits](#no-rate-limits)
14-
* [Rapid Building of New Versions](#rapid-building-of-new-versions)
15-
* [Regular Updates](#regular-updates)
16-
* [How To](#how-to)
17-
* [Using the Full Image](#using-the-full-image)
18-
* [Using the Slim Image](#using-the-slim-image)
19-
* [Copy Just the Packages](#copy-just-the-packages)
20-
* [Add Your App](#add-your-app)
21-
* [PreStart Script](#prestart-script)
22-
* [Environmental Variables](#environmental-variables)
23-
* [PORT](#port)
24-
* [WORKERS](#workers)
25-
* [LOG_LEVEL](#log_level)
26-
* [MODULE_NAME](#module_name)
27-
* [VARIABLE_NAME](#variable_name)
28-
* [APP_MODULE](#app_module)
29-
* [PRE_START_PATH](#pre_start_path)
30-
* [RELOAD](#reload)
31-
* [Python Versions](#python-versions)
32-
* [Image Variants](#image-variants)
33-
* [Full](#full)
34-
* [Slim](#slim)
35-
* [Architectures](#architectures)
36-
* [Sponsorship](#sponsorship)
37-
* [Tags](#tags)
38-
* [Older Tags](#older-tags)
10+
* [Benefits](#benefits)
11+
* [Multi Architecture Builds](#multi-architecture-builds)
12+
* [Small Images via Multi Stage Builds](#small-images-via-multi-stage-builds)
13+
* [No Rate Limits](#no-rate-limits)
14+
* [Rapid Building of New Versions](#rapid-building-of-new-versions)
15+
* [Regular Updates](#regular-updates)
16+
* [How To](#how-to)
17+
* [Using the Full Image](#using-the-full-image)
18+
* [Using the Slim Image](#using-the-slim-image)
19+
* [Copy Just the Packages](#copy-just-the-packages)
20+
* [Add Your App](#add-your-app)
21+
* [PreStart Script](#prestart-script)
22+
* [Environmental Variables](#environmental-variables)
23+
* [PORT](#port)
24+
* [WORKERS](#workers)
25+
* [LOG_LEVEL](#log_level)
26+
* [MODULE_NAME](#module_name)
27+
* [VARIABLE_NAME](#variable_name)
28+
* [APP_MODULE](#app_module)
29+
* [PRE_START_PATH](#pre_start_path)
30+
* [RELOAD](#reload)
31+
* [Python Versions](#python-versions)
32+
* [Image Variants](#image-variants)
33+
* [Full](#full)
34+
* [Slim](#slim)
35+
* [Architectures](#architectures)
36+
* [Sponsorship](#sponsorship)
37+
* [Tags](#tags)
38+
* [Older Tags](#older-tags)
3939
<!--te-->
4040

4141
## Benefits
@@ -68,6 +68,7 @@ Containers are rebuilt weekly in order to take on the security patches from upst
6868
## How To
6969

7070
### Using the Full Image
71+
7172
The Full Images use the base Python Docker images as their parent. These images are based off of Ubuntu and contain a variety of build tools.
7273

7374
To pull the latest full version:
@@ -103,6 +104,7 @@ FROM ghcr.io/multi-py/python-gunicorn-uvicorn:py3.11-slim-LATEST
103104

104105

105106
### Copy Just the Packages
107+
106108
It's also possible to copy just the Python packages themselves. This is particularly useful when you want to use the precompiled libraries from multiple containers.
107109

108110
```dockerfile
@@ -181,6 +183,17 @@ Where to find the prestart script.
181183

182184
When this is set to the string `true` uvicorn is launched in reload mode. If any files change uvicorn will reload the modules again, allowing for quick debugging. This comes at a performance cost, however, and should not be enabled on production machines.
183185

186+
187+
### `GUNICORN_EXTRA_FLAGS`
188+
189+
This variable can be used to pass extra flags to the `gunicorn` command on launch. It's value is added directly to the command that is called, and has to be formatted appropriately for the command line.
190+
191+
192+
### `UVICORN_EXTRA_FLAGS`
193+
194+
This variable can be used to pass extra flags to the `uvicorn` command on launch. It's value is added directly to the command that is called, and has to be formatted appropriately for the command line.
195+
196+
184197
## Python Versions
185198

186199
This project actively supports these Python versions:
@@ -230,6 +243,7 @@ If you get use out of these containers please consider sponsoring me using Githu
230243
</center>
231244

232245
## Tags
246+
233247
* Recommended Image: `ghcr.io/multi-py/python-gunicorn-uvicorn:py3.11-0.23.2`
234248
* Slim Image: `ghcr.io/multi-py/python-gunicorn-uvicorn:py3.11-slim-0.23.2`
235249

assets/start.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME}
1515
VARIABLE_NAME=${VARIABLE_NAME:-app}
1616
export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"}
1717

18-
1918
# If there's a prestart.sh script in the /app directory or other path specified, run it before starting
2019
PRE_START_PATH=${PRE_START_PATH:-/app/prestart.sh}
2120
echo "Checking for script in $PRE_START_PATH"
22-
if [ -f $PRE_START_PATH ] ; then
21+
if [ -f $PRE_START_PATH ]; then
2322
echo "Running script $PRE_START_PATH"
2423
. "$PRE_START_PATH"
2524
else
@@ -30,9 +29,8 @@ fi
3029
# End of tiangolo/uvicorn-gunicorn-docker block
3130
#
3231

33-
3432
if [[ $RELOAD == "true" ]]; then
35-
exec python -m gunicorn "$APP_MODULE" -k uvicorn.workers.UvicornWorker -k gevent -w ${WORKERS:-4} -b ${HOST:-0.0.0.0}:${PORT:-80} --log-level "${LOG_LEVEL:-info}" --reload
33+
exec python -m gunicorn "$APP_MODULE" $GUNICORN_EXTRA_FLAGS -k uvicorn.workers.UvicornWorker $UVICORN_EXTRA_FLAGS -k gevent -w ${WORKERS:-4} -b ${HOST:-0.0.0.0}:${PORT:-80} --log-level "${LOG_LEVEL:-info}" --reload
3634
else
37-
exec python -m gunicorn "$APP_MODULE" -k uvicorn.workers.UvicornWorker -k gevent -w ${WORKERS:-4} -b ${HOST:-0.0.0.0}:${PORT:-80} --log-level "${LOG_LEVEL:-info}"
35+
exec python -m gunicorn "$APP_MODULE" $GUNICORN_EXTRA_FLAGS -k uvicorn.workers.UvicornWorker $UVICORN_EXTRA_FLAGS -k gevent -w ${WORKERS:-4} -b ${HOST:-0.0.0.0}:${PORT:-80} --log-level "${LOG_LEVEL:-info}"
3836
fi

0 commit comments

Comments
 (0)