Browse Source

Merge branch 'main' of http://git2.simplico.net/tum/coi

tum 1 year ago
parent
commit
e51c0569c5
2 changed files with 26 additions and 10 deletions
  1. 25 10
      app/coi/settings.py
  2. 1 0
      docker-compose.yml

+ 25 - 10
app/coi/settings.py

12
 
12
 
13
 from pathlib import Path
13
 from pathlib import Path
14
 import os
14
 import os
15
-
15
+from pprint import pprint
16
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
16
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
17
 BASE_DIR = Path(__file__).resolve().parent.parent
17
 BASE_DIR = Path(__file__).resolve().parent.parent
18
 
18
 
26
 # SECURITY WARNING: don't run with debug turned on in production!
26
 # SECURITY WARNING: don't run with debug turned on in production!
27
 DEBUG = True
27
 DEBUG = True
28
 
28
 
29
+DJANGO_ENV = os.getenv("DJANGO_ENV", "dev")  # Default to 'dev' if not set
30
+pprint(f"ENV = {DJANGO_ENV}")
29
 ALLOWED_HOSTS = []
31
 ALLOWED_HOSTS = []
30
 
32
 
31
 
33
 
86
 
88
 
87
 # Database
89
 # Database
88
 # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
90
 # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
91
+DJANGO_ENV = os.getenv("DJANGO_ENV", "dev")  # Default to 'dev' if not set
92
+if DJANGO_ENV == "dev":
93
+    DB_NAME = os.environ.get('DB_NAME', 'coi_db')
94
+    DB_USER =  os.environ.get('DB_USER', 'sa')
95
+    DB_PASSWORD = os.environ.get('DB_PASSWORD', '')
96
+    DB_HOST =  os.environ.get('DB_HOST', 'db')
97
+    DB_PORT = os.environ.get('DB_PORT', '1433')
98
+else:
99
+    DB_NAME = "coi_db"
100
+    DB_USER =  "user1"
101
+    DB_PASSWORD = "1234"
102
+    DB_HOST =  "192.168.0.253"
103
+    DB_PORT = '1433'
89
 
104
 
90
 DATABASES = {
105
 DATABASES = {
91
     'default': {
106
     'default': {
92
         'ENGINE': 'mssql',
107
         'ENGINE': 'mssql',
93
-        'NAME': os.environ.get('DB_NAME', 'coi_db'),
94
-        'USER': os.environ.get('DB_USER', 'sa'),
95
-        'PASSWORD': os.environ.get('DB_PASSWORD', ''),
96
-        'HOST': os.environ.get('DB_HOST', 'db'),
97
-        'PORT': os.environ.get('DB_PORT', '1433'),
108
+        'NAME': DB_NAME,
109
+        'USER': DB_USER,
110
+        'PASSWORD': DB_PASSWORD,
111
+        'HOST': DB_HOST,
112
+        'PORT': DB_PORT,
98
         'OPTIONS': {
113
         'OPTIONS': {
99
             'driver': 'ODBC Driver 18 for SQL Server',
114
             'driver': 'ODBC Driver 18 for SQL Server',
100
             'extra_params':  'Encrypt=no',
115
             'extra_params':  'Encrypt=no',
103
     'OB2011DB': {
118
     'OB2011DB': {
104
         'ENGINE': 'mssql',
119
         'ENGINE': 'mssql',
105
         'NAME': 'OB2011DB',
120
         'NAME': 'OB2011DB',
106
-        'USER': os.environ.get('DB_USER', 'sa'),
107
-        'PASSWORD': os.environ.get('DB_PASSWORD', ''),
108
-        'HOST': os.environ.get('DB_HOST', 'db'),
109
-        'PORT': os.environ.get('DB_PORT', '1433'),
121
+        'USER': DB_USER,
122
+        'PASSWORD': DB_PASSWORD,
123
+        'HOST': DB_HOST,
124
+        'PORT': DB_PORT,
110
         'OPTIONS': {
125
         'OPTIONS': {
111
             'driver': 'ODBC Driver 18 for SQL Server',
126
             'driver': 'ODBC Driver 18 for SQL Server',
112
             'extra_params':  'Encrypt=no',
127
             'extra_params':  'Encrypt=no',

+ 1 - 0
docker-compose.yml

35
         condition: service_started
35
         condition: service_started
36
         #condition: service_healthy
36
         #condition: service_healthy
37
     environment:
37
     environment:
38
+      DJANGO_ENV: "dev"
38
       DB_NAME: "coi_db"
39
       DB_NAME: "coi_db"
39
       DB_USER: "sa"
40
       DB_USER: "sa"
40
       DB_PASSWORD: "StrongPassw0rd!"
41
       DB_PASSWORD: "StrongPassw0rd!"