diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 8c4feb36..fec6df45 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -25,7 +25,7 @@ steps: '--platform', 'managed', '--allow-unauthenticated', '--add-cloudsql-instances', '${_CLOUDSQL_INSTANCE_CONNECTION_NAME}', - '--set-env-vars', 'GOOGLE_CLOUD_PROJECT=$PROJECT_ID,SETTINGS_NAME=mle_django_settings', + '--set-env-vars', 'GOOGLE_CLOUD_PROJECT=$PROJECT_ID,SETTINGS_NAME=mle_django_settings,DJANGO_SETTINGS_MODULE=config.settings.production', '--min-instances', '1' ] diff --git a/config/settings/production.py b/config/settings/production.py index dc7e9389..fcd77037 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -118,7 +118,7 @@ # django-compressor # ------------------------------------------------------------------------------ # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED -COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True) +COMPRESS_ENABLED = True # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL COMPRESS_URL = STATIC_URL # noqa F405 # https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE diff --git a/entrypoint b/entrypoint old mode 100644 new mode 100755 index 3e14e425..dbf3d28f --- a/entrypoint +++ b/entrypoint @@ -4,32 +4,6 @@ set -o errexit set -o pipefail set -o nounset -postgres_ready() { -python << END -import sys - -import psycopg2 - -try: - psycopg2.connect( - dbname="${POSTGRES_DB}", - user="${POSTGRES_USER}", - password="${POSTGRES_PASSWORD}", - host="${POSTGRES_HOST}", - port="${POSTGRES_PORT}", - ) -except psycopg2.OperationalError: - sys.exit(-1) -sys.exit(0) - -END -} -until postgres_ready; do - >&2 echo 'Waiting for PostgreSQL to become available...' - sleep 1 -done ->&2 echo 'PostgreSQL is available' - python /app/manage.py migrate >&2 echo 'Ran database migrations...' @@ -39,26 +13,8 @@ python /app/manage.py createcachetable python /app/manage.py collectstatic --noinput >&2 echo 'Collected static files...' -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 - >&2 echo 'Compressed static assets...' -fi +python /app/manage.py compress +>&2 echo 'Compressed static assets...' >&2 echo 'About to run Gunicorn...' /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:$PORT --chdir=/app -k uvicorn.workers.UvicornWorker