From 4ef36b2e7d113a2e7ad680a33fa649299b58638c Mon Sep 17 00:00:00 2001 From: alex-phillips Date: Thu, 22 Nov 2018 10:54:24 -0500 Subject: [PATCH] use uwsgi instead of python built-in server, disable debug mode by default in config --- Dockerfile | 4 +++- root/defaults/uwsgi.ini | 10 ++++++++++ root/etc/cont-init.d/30-config | 3 +++ .../{healthchecks_alerts => healthchecks}/run | 2 +- root/etc/services.d/healthchecks_server/run | 6 ------ 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 root/defaults/uwsgi.ini rename root/etc/services.d/{healthchecks_alerts => healthchecks}/run (53%) delete mode 100644 root/etc/services.d/healthchecks_server/run diff --git a/Dockerfile b/Dockerfile index c49c562..ab13123 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,9 @@ RUN \ zlib-dev && \ echo "**** install runtime packages ****" && \ apk add --no-cache \ - python3 && \ + python3 \ + uwsgi \ + uwsgi-python3 && \ echo "**** install healthchecks ****" && \ mkdir -p /app/healthchecks && \ if [ -z ${HEALTHCHECKS_RELEASE+x} ]; then \ diff --git a/root/defaults/uwsgi.ini b/root/defaults/uwsgi.ini new file mode 100644 index 0000000..a9a2de8 --- /dev/null +++ b/root/defaults/uwsgi.ini @@ -0,0 +1,10 @@ +[uwsgi] +http-socket = :8000 +enable-threads +plugin = python3 +module = hc.wsgi:application +static-map = /static=static-collected +static-gzip-dir = static-collected/CACHE +hook-pre-app = exec:/usr/bin/python3 ./manage.py collectstatic --noinput +hook-pre-app = exec:/usr/bin/python3 ./manage.py compress +attach-daemon = /usr/bin/python3 ./manage.py sendalerts diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index b0734f2..e28efce 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -2,6 +2,7 @@ # set default values for variables declare -A HC_CONF +HC_CONF[DEBUG]=${DEBUG:-False} HC_CONF[SITE_ROOT]=${SITE_ROOT:-https://healthchecks.example.com} HC_CONF[SITE_NAME]=${SITE_NAME:-healthchecks} HC_CONF[DEFAULT_FROM_EMAIL]=${DEFAULT_FROM_EMAIL:-noreply@example.com} @@ -33,6 +34,8 @@ if [ ! -d "/config/img" ]; then mkdir /config/img fi +mv /defaults/uwsgi.ini /app/healthchecks/uwsgi.ini > /dev/null 2>&1 + # copy over configurable logo files FILES="favicon.ico apple-touch-180.png diff --git a/root/etc/services.d/healthchecks_alerts/run b/root/etc/services.d/healthchecks/run similarity index 53% rename from root/etc/services.d/healthchecks_alerts/run rename to root/etc/services.d/healthchecks/run index 72eb79a..5422d3a 100644 --- a/root/etc/services.d/healthchecks_alerts/run +++ b/root/etc/services.d/healthchecks/run @@ -3,4 +3,4 @@ cd /app/healthchecks || exit exec \ - s6-setuidgid abc /usr/bin/python3 ./manage.py sendalerts + s6-setuidgid abc /usr/sbin/uwsgi uwsgi.ini diff --git a/root/etc/services.d/healthchecks_server/run b/root/etc/services.d/healthchecks_server/run deleted file mode 100644 index 293e9f3..0000000 --- a/root/etc/services.d/healthchecks_server/run +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/with-contenv bash - -cd /app/healthchecks || exit - -exec \ - s6-setuidgid abc /usr/bin/python3 ./manage.py runserver 0.0.0.0:8000