From 7878ecda2ae3e9c70d93457bd04ef8eee80141b9 Mon Sep 17 00:00:00 2001 From: James Swineson Date: Fri, 12 Jul 2019 22:20:59 +0800 Subject: [PATCH] allow setting gunicorn default args via environment variables --- docker/Production/Dockerfile | 2 +- docker/Production/entrypoint.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docker/Production/Dockerfile b/docker/Production/Dockerfile index 1f1aea9..45489a8 100644 --- a/docker/Production/Dockerfile +++ b/docker/Production/Dockerfile @@ -29,4 +29,4 @@ RUN chmod +x /usr/local/bin/entrypoint.sh ENV FLASK_APP=app/__init__.py EXPOSE 80/tcp ENTRYPOINT ["entrypoint.sh"] -CMD ["gunicorn", "-t", "120", "--workers", "4", "--bind", "0.0.0.0:80", "--log-level", "info" ,"app:app"] +CMD ["gunicorn","app:app"] diff --git a/docker/Production/entrypoint.sh b/docker/Production/entrypoint.sh index 215a9ab..f705d35 100644 --- a/docker/Production/entrypoint.sh +++ b/docker/Production/entrypoint.sh @@ -2,12 +2,19 @@ set -Eeuo pipefail cd /opt/powerdns-admin +GUNICORN_TIMEOUT="${GUINCORN_TIMEOUT:-120}" +GUNICORN_WORKERS="${GUNICORN_WORKERS:-4}" +GUNICORN_LOGLEVEL="${GUNICORN_LOGLEVEL:-info}" + if [ ! -f ./config.py ]; then cat ./config_template.py ./docker/Production/config_docker.py > ./config.py fi +GUNICORN_ARGS="-t ${GUNICORN_TIMEOUT} --workers ${GUNICORN_WORKERS} --bind 0.0.0.0:80 --log-level ${GUNICORN_LOGLEVEL}" if [ "$1" == gunicorn ]; then flask db upgrade -fi + exec "$@" $GUNICORN_ARGS -exec "$@" +else + exec "$@" +fi