From 866cb4977029dd23530edcad4c12b6f9d6cc95d9 Mon Sep 17 00:00:00 2001 From: Dara Keon Date: Sat, 15 Jul 2023 17:15:40 +0100 Subject: [PATCH] midna: move db config to env --- midna/env/example.env | 6 ++++++ midna/src/midna/settings.py | 10 +++++----- publish/dfm-midna.dockerfile | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/midna/env/example.env b/midna/env/example.env index 78c64e2539..7b01b22ede 100644 --- a/midna/env/example.env +++ b/midna/env/example.env @@ -2,6 +2,12 @@ DJANGO_SUPERUSER_USERNAME=username DJANGO_SUPERUSER_EMAIL=email DJANGO_SUPERUSER_PASSWORD=password +DATABASE_NAME=dfm +DATABASE_USER=dfm_user +DATABASE_PASS= +DATABASE_HOST=172.17.0.1 +DATABASE_PORT=3306 + AWS_BUCKET= AWS_DEFAULT_REGION= AWS_ACCESS_KEY_ID= diff --git a/midna/src/midna/settings.py b/midna/src/midna/settings.py index d58754f8b6..e687d38318 100644 --- a/midna/src/midna/settings.py +++ b/midna/src/midna/settings.py @@ -90,11 +90,11 @@ }, 'mysql': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'dfm', - 'USER': 'dfm_user', - 'PASSWORD': '', - 'HOST': '172.17.0.1', - 'PORT': '3306', + 'NAME': environ['DATABASE_NAME'], + 'USER': environ['DATABASE_USER'], + 'PASSWORD': environ['DATABASE_PASS'], + 'HOST': environ['DATABASE_HOST'], + 'PORT': environ['DATABASE_PORT'], 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" } diff --git a/publish/dfm-midna.dockerfile b/publish/dfm-midna.dockerfile index b28c121036..ce78d28c06 100755 --- a/publish/dfm-midna.dockerfile +++ b/publish/dfm-midna.dockerfile @@ -16,6 +16,12 @@ WORKDIR /var/midna/src RUN mkdir /var/midna/static RUN mkdir /var/midna/static/inside RUN mkdir /var/midna/static/outside -RUN SECRET_KEY=temp python3 manage.py collectstatic +RUN SECRET_KEY=collectstatic \ + DATABASE_NAME= \ + DATABASE_USER= \ + DATABASE_PASS= \ + DATABASE_HOST= \ + DATABASE_PORT= \ + python3 manage.py collectstatic CMD cp -r ../static/inside/* ../static/outside && gunicorn -c ../config/prod.py