Skip to content

Commit

Permalink
portia_server: read settings from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu committed Apr 4, 2022
1 parent b3fa298 commit ef5a6d8
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions portia_server/portia_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.realpath(os.path.join(BASE_DIR, '../portiaui/dist'))
STATIC_URL = '/'
BASE_DIR = os.environ.get('BASE_DIR', os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_ROOT = os.environ.get('STATIC_ROOT', os.path.realpath(os.path.join(BASE_DIR, '../portiaui/dist')))
STATIC_URL = os.environ.get('STATIC_URL', '/')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_ROOT = os.path.abspath(os.path.join(BASE_DIR, '../data/projects'))
MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.abspath(os.path.join(BASE_DIR, '../data/projects')))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'x8#v=v_yen3pvul&2*-x3=td2eqvw%5!*qaf^g8vzu#gcyo+%n'
SECRET_KEY = os.environ.get('SECRET_KEY', 'x8#v=v_yen3pvul&2*-x3=td2eqvw%5!*qaf^g8vzu#gcyo+%n')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = bool(os.environ.get('DEBUG', True))

ALLOWED_HOSTS = [
'*'
Expand Down Expand Up @@ -65,10 +65,14 @@
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases

SQLITE_PATH = os.environ.get('SQLITE_PATH', os.path.join(BASE_DIR, 'db.sqlite3'))
d = os.path.dirname(SQLITE_PATH)
os.makedirs(d, exist_ok=True)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': SQLITE_PATH,
}
}

Expand All @@ -94,15 +98,15 @@
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = os.environ.get('LANGUAGE_CODE', 'en-us')

TIME_ZONE = 'UTC'
TIME_ZONE = os.environ.get('TIME_ZONE', 'UTC')

USE_I18N = True
USE_I18N = bool(os.environ.get('USE_I18N', True))

USE_L10N = True
USE_L10N = bool(os.environ.get('USE_L10N', True))

USE_TZ = True
USE_TZ = bool(os.environ.get('USE_TZ', True))

PORTIA_STORAGE_BACKEND = os.environ.get('PORTIA_STORAGE_BACKEND',
'storage.backends.FsStorage')
Expand Down

0 comments on commit ef5a6d8

Please sign in to comment.