diff --git a/Dockerfile b/Dockerfile index 59d42084..35fef53f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,6 @@ RUN pip install --no-cache-dir /deps/*.whl COPY --from=builder /doccano /doccano -ENV IS_HEROKU="False" ENV DEBUG="True" ENV SECRET_KEY="change-me-in-production" ENV PORT="80" diff --git a/app/app/settings.py b/app/app/settings.py index c4e804d4..2bd86126 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -195,6 +195,8 @@ LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/projects/' LOGOUT_REDIRECT_URL = '/' +django_heroku.settings(locals(), test_runner=False) + # Change 'default' database configuration with $DATABASE_URL. DATABASES['default'].update(dj_database_url.config( env='DATABASE_URL', @@ -202,6 +204,10 @@ DATABASES['default'].update(dj_database_url.config( ssl_require='sslmode' not in furl(env('DATABASE_URL', '')).args, )) +# work-around for dj-database-url: explicitly disable ssl for sqlite +if DATABASES['default'].get('ENGINE') == 'django.db.backends.sqlite3': + DATABASES['default'].get('OPTIONS', {}).pop('sslmode', None) + # Honor the 'X-Forwarded-Proto' header for request.is_secure() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') @@ -218,11 +224,3 @@ AZURE_APPINSIGHTS_IKEY = env('AZURE_APPINSIGHTS_IKEY', None) APPLICATION_INSIGHTS = { 'ikey': AZURE_APPINSIGHTS_IKEY if AZURE_APPINSIGHTS_IKEY else None, } - -# work-around for django-heroku: don't overwrite sslmode outside of heroku -if env.bool('IS_HEROKU', True): - django_heroku.settings(locals(), test_runner=False) - -# work-around for dj-database-url: explicitly disable ssl for sqlite -if DATABASES['default'].get('ENGINE') == 'django.db.backends.sqlite3': - DATABASES['default'].get('OPTIONS', {}).pop('sslmode', None) diff --git a/app/server/tests/test_config.py b/app/server/tests/test_config.py index f1bcfd84..7a175d3d 100644 --- a/app/server/tests/test_config.py +++ b/app/server/tests/test_config.py @@ -17,8 +17,7 @@ class TestDatabaseUrl(TestCase): self._assert_sslmode_is(None) def test_sslmode_can_be_set_via_database_url(self): - with setenv('DATABASE_URL', 'pgsql://u:p@h/d?sslmode=disabled'), \ - setenv('IS_HEROKU', 'False'): + with setenv('DATABASE_URL', 'pgsql://u:p@h/d?sslmode=disabled'): self._assert_sslmode_is('disabled') def _assert_sslmode_is(self, expected):