Skip to content
Snippets Groups Projects
Verified Commit 8585c185 authored by Tanner Prestegard's avatar Tanner Prestegard
Browse files

Require DJANGO_DB_USER and DJANGO_REPLICA_DB_USER

These environment variables are now required.  Previously, the
corresponding Django settings would default to 'gracedb'.
parent deac2120
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,7 @@ RUN mkdir /app/logs /app/project_data
WORKDIR /app/gracedb_project
RUN DJANGO_SETTINGS_MODULE=${SETTINGS_MODULE} \
DJANGO_DB_NAME=fake_name \
DJANGO_DB_USER=fake_user \
DJANGO_DB_PASSWORD=fake_password \
DJANGO_SECRET_KEY=fake_key \
DJANGO_PRIMARY_FQDN=fake_fqdn \
......
# For running a containerized version of the service that gets secrets
# from environment variables. Builds on base.py settings.
import os
from django.core.exceptions import ImproperlyConfigured
from ..base import *
# Get required variables from environment variables ---------------------------
# Get database user from environment and check
db_user = os.environ.get('DJANGO_DB_USER', None)
if db_user is None:
raise ImproperlyConfigured('Could not get database user from envvars.')
# Get database password from environment and check
db_password = os.environ.get('DJANGO_DB_PASSWORD', None)
if db_password is None:
......@@ -72,7 +76,7 @@ DATABASES = {
'default' : {
'NAME': db_name,
'ENGINE': 'django.db.backends.mysql',
'USER': os.environ.get('DJANGO_DB_USER', 'gracedb'),
'USER': db_user,
'PASSWORD': db_password,
'HOST': os.environ.get('DJANGO_DB_HOST', ''),
'PORT': os.environ.get('DJANGO_DB_PORT', ''),
......
# Settings for a test/dev GraceDB instance running in a container
#import socket
from .base import *
CONFIG_NAME = "TEST"
......
# Settings for a production GraceDB instance running in a container
import copy
from django.core.exceptions import ImproperlyConfigured
from .base import *
......@@ -35,6 +34,10 @@ else:
if replica_db_name is None:
raise ImproperlyConfigured('Could not get replica database name from '
'envvars.')
replica_db_user = os.environ.get('DJANGO_REPLICA_DB_USER', None)
if replica_db_user is None:
raise ImproperlyConfigured('Could not get replica database user '
'from envvars.')
replica_db_password = os.environ.get('DJANGO_REPLICA_DB_PASSWORD', None)
if replica_db_password is None:
raise ImproperlyConfigured('Could not get replica database password '
......@@ -44,7 +47,7 @@ else:
read_replica = {
'NAME': replica_db_name,
'ENGINE': 'django.db.backends.mysql',
'USER': os.environ.get('DJANGO_REPLICA_DB_USER', 'gracedb'),
'USER': replica_db_user,
'PASSWORD': replica_db_password,
'HOST': os.environ.get('DJANGO_REPLICA_DB_HOST', ''),
'PORT': os.environ.get('DJANGO_REPLICA_DB_PORT', ''),
......
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