From d3db7a867fbf58b80ceea4dc05829a2fcbbdbe60 Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 28 Feb 2020 17:04:15 +0000 Subject: [PATCH] fix compresss offline never runs using environ --- .../compose/production/django/start | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start index a3aa1161..4985aeed 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/start +++ b/{{cookiecutter.project_slug}}/compose/production/django/start @@ -6,9 +6,24 @@ set -o nounset python /app/manage.py collectstatic --noinput -{%- if cookiecutter.use_whitenoise == 'y' and cookiecutter.use_compressor == 'y' %} -if [ "${COMPRESS_ENABLED:-}" = "True" ]; -then +{% if cookiecutter.use_whitenoise == 'y' and cookiecutter.use_compressor == 'y' %} +compress_enabled() { +python << END +import sys + +from environ import Env + +env = Env(COMPRESS_ENABLED=(bool, True)) +if env('COMPRESS_ENABLED'): + sys.exit(0) +else: + sys.exit(1) + +END +} + +if compress_enabled; then + # NOTE this command will fail if django-compressor is disabled python /app/manage.py compress fi {%- endif %}