Skip to content
Snippets Groups Projects
Commit 544fdfea authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

~ move all local settings to .env file

parent 62169af6
No related branches found
No related tags found
1 merge request!13Adaptation for an AuRa wide docker setup
# This has to be set to any good enough random string. E.g. something that
# `pwgen -s 32 1` would print out. If you want to know more about this go to
# https://docs.djangoproject.com/en/3.2/ref/settings/#secret-key
# (mandatory setting)
SECRET_KEY=put-something-awesomely-random-here
# A comma-separated list of hostnames/IPs Django should listen to. For a
# production setup this will be something like aura.example.org, for a dev
# setup you might just use the default settings.
# (default: 127.0.0.1, localhost)
#ALLOWED_HOSTS=
# A comma-separated list of URIs where the webclients live that should be able
# to access the steering API. In particular the dashboard. Might not be needed
# in a production setup if steering and dashboard share the same domain. In
# a dev setup the defaults might be just fine.
# (default: http://127.0.0.1:8080, http://localhost:8080)
#CORS_ORIGIN_WHITELIST=
# The database settings.
# if you use a dev environment where django is not running inside a docker
# container, but you use the postgres container for the db and map its port,
# then use localhost as the database hostname
# (default host: steering-postgres)
# (default port: 5432)
# (default name: steering)
# (default user: steering)
# (pass is a mandatory setting)
#DBHOST=
#DBPORT=
#DBNAME=
#DBUSER=
DBPASS=change-to-something-secure
# The timezone of this server. For a list of all available tz database names see
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# (default: Europe/Vienna)
#TIME_ZONE=
# The language code for the localization of this server. For a list of available
# codes see http://www.i18nguy.com/unicode/language-identifiers.html
# (default: de)
#LANGUAGE_CODE=
# If steering is run inside a docker container. This will be de default for a
# production deployment. In a dev scenario you might still want to have the
# database in its container, but run the steering dev server directly on your
# host. In this case make this False.
# (default: True)
#RUNINDOCKER=
# This should be turned on only for your development environment unless you
# know exactly what you are doing and what the consequences are.
# (default: False)
#DEBUG=
import os
from corsheaders.defaults import default_headers
CONFIG_DIR = '/etc/aura/'
DB_CONFIG = 'steering.mysql.cnf'
SECRET_KEY = '---some-secred-key---'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': os.path.join(CONFIG_DIR, DB_CONFIG),
},
}
}
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = (
'http://localhost:8080'
# 'https://aura-test.o94.at',
# 'https://aura-test.o94.at:443',
)
CORS_ALLOW_HEADERS = list(default_headers) + [
'content-disposition',
]
# Comment out the following for temporary debugging, if you want to use the
# native DRF web forms
"""
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
],
}
"""
# Django settings for pv project.
import os.path
import environ
from corsheaders.defaults import default_headers
# Paths
......@@ -18,35 +20,46 @@ STATIC_URL = '/static/'
ROOT_URLCONF = 'pv.urls'
DEBUG = True
env = environ.Env()
env.read_env(env_file=PROJECT_DIR+'/../.env')
env.str('DBHOST')
DOCKER = env.bool('DOCKER', default=True)
DEBUG = env.bool('DEBUG', default=False)
SITE_ID = 1
ADMINS = ()
MANAGERS = ADMINS
# Must be set if DEBUG is False
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
ALLOWED_HOSTS = env.list('HOSTNAMES', default=['127.0.0.1', 'localhost'])
# Whitelist IPs that access the API
CORS_ORIGIN_WHITELIST = (
'http://localhost',
'http://localhost:8080'
)
CORS_ORIGIN_WHITELIST = env.list('CORS_ORIGIN_WHITELIST', default=(
'http://localhost:8080',
'http://127.0.0.1:8080'
))
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_HEADERS = list(default_headers) + [
'content-disposition',
]
# Define which database backend to use for our apps
DATABASES = {
# SQLITE
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_DIR, 'dev_data.sqlite'),
},
#'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(PROJECT_DIR, 'dev_data.sqlite'),
#},
# PostgreSQL
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'OPTIONS': {
# 'read_default_file': os.path.join(PROJECT_DIR, 'postgresql.cnf'),
# },
# },
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': env.str('DBNAME', default='steering'),
'USER': env.str('DBUSER', default='steering'),
'PASSWORD': env.str('DBPASS'),
'HOST': env.str('DBHOST', default='steering-postgres'),
'PORT': env.str('DBPORT', '5432'),
},
# MySQL
# 'default': {
......@@ -55,18 +68,17 @@ DATABASES = {
# 'read_default_file': os.path.join(PROJECT_DIR, 'mysql.cnf'),
# },
# },
}
CACHE_BACKEND = 'locmem://'
# LOCALIZATION
TIME_ZONE = 'Europe/Vienna'
LANGUAGE_CODE = 'de'
TIME_ZONE = env.str('TIME_ZONE', default='Europe/Vienna')
LANGUAGE_CODE = env.str('LANGUAGE_CODE', default='de')
USE_I18N = True
USE_L10N = True
SECRET_KEY = ''
SECRET_KEY = env.str('SECRET_KEY')
TEMPLATES = [
{
......
......@@ -3,8 +3,15 @@ django-cors-headers==3.2.1
django-oidc-provider==0.7.0
django-tinymce==2.8.0
django-versatileimagefield==1.11
django-environ==0.4.5
djangorestframework==3.11.0
drf-nested-routers==0.91
Pillow==4.3.0
python-dateutil==2.8.1
PyYAML==3.13
# needed for the database (container)
psycopg2_binary==2.8.6
# needed for production server
gunicorn==20.0.4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment