Commit de1ee339 authored by Daniel Schreiber's avatar Daniel Schreiber

prepare for running in docker container

parent b4656dfd
Pipeline #28142 failed with stage
in 22 seconds
......@@ -2,6 +2,9 @@
from __future__ import unicode_literals
import sys
import os.path
import os
import random
import string
from .common import *
......@@ -90,33 +93,45 @@ gespeichert:
- `SECRET_KEY`
- Sonstige Geheimnisse, wie LDAP-Passwörter o.ä.
"""
sys.path.append(os.path.normpath(os.path.join(
os.path.dirname(__file__), "..", "..", "..", "private")))
from settings_private import *
private_dir = os.path.normpath(os.path.join(
os.path.dirname(__file__), "..", "..", "..", "private"))
sys.path.append(private_dir)
if os.environ.get("DOCKER", "") == "1":
secrets_file = os.path.join(private_dir, "django_secret.txt")
if not os.path.exists(secrets_file):
key = "".join([random.SystemRandom().choice(string.digits + string.ascii_letters + "!#$%&()*+,-./:;<=>?@[]^_`{|}~") for i in range(60)])
with open(secrets_file, "w") as f:
f.write(key)
with open(secrets_file, "r") as f:
SECRET_KEY = f.readline().strip()
from settings_docker import *
else:
from settings_private import *
# Mindestens eine Datenbank muss als 'default' konfiguriert werden.
DATABASES = {
'example_postgres': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'datenbank',
'USER': 'datenbank_rw',
'PASSWORD': DATABASE_PASSWORD, # @UndefinedVariable
'HOST': 'pgsql.hrz.tu-chemnitz.de',
},
'example_mysql': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'datenbank',
'USER': 'datenbank_rw',
'PASSWORD': DATABASE_PASSWORD, # @UndefinedVariable
'HOST': 'mysql.hrz.tu-chemnitz.de',
'OPTIONS': {
'init_command': ('SET storage_engine=INNODB,'
'character_set_connection=utf8,'
'collation_connection=utf8_bin'),
}
},
}
try:
from settings_local import *
except:
pass
DATABASES = {
'example_postgres': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'datenbank',
'USER': 'datenbank_rw',
'PASSWORD': DATABASE_PASSWORD, # @UndefinedVariable
'HOST': 'pgsql.hrz.tu-chemnitz.de',
},
'example_mysql': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'datenbank',
'USER': 'datenbank_rw',
'PASSWORD': DATABASE_PASSWORD, # @UndefinedVariable
'HOST': 'mysql.hrz.tu-chemnitz.de',
'OPTIONS': {
'init_command': ('SET storage_engine=INNODB,'
'character_set_connection=utf8,'
'collation_connection=utf8_bin'),
}
},
}
try:
from settings_local import *
except:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment