Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit c29061a2 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Get DB name from environment for containerized version

parent 92056652
......@@ -40,19 +40,14 @@ RUN pip install -r requirements.txt
# Give pip-installed packages priority over distribution packages
ENV PYTHONPATH /usr/local/lib/python2.7/dist-packages:$PYTHONPATH
# Collect static components. First step: set settings module and
# fake a few other required environment variables
ENV DJANGO_SETTINGS_MODULE ${SETTINGS_MODULE}
ENV DJANGO_DB_PASSWORD fake_password
ENV DJANGO_SECRET_KEY fake_key
ENV DJANGO_PRIMARY_FQDN fake_fqdn
RUN python manage.py collectstatic --noinput
# Unset faked environment variables
RUN unset DJANGO_SETTINGS_MODULE \
DJANGO_DB_PASSWORD \
DJANGO_SECRET_KEY \
DJANGO_PRIMARY_FQDN
# Collect static components. Have to set a settings module envvar
# and fake a few other required environment variables
RUN DJANGO_SETTINGS_MODULE=${SETTINGS_MODULE} \
DJANGO_DB_NAME=fake_name \
DJANGO_DB_PASSWORD=fake_password \
DJANGO_SECRET_KEY=fake_key \
DJANGO_PRIMARY_FQDN=fake_fqdn \
python manage.py collectstatic --noinput
# Expose port and run Gunicorn
EXPOSE 8000
......
......@@ -7,10 +7,15 @@ from ..base import *
# Get required variables from environment variables ---------------------------
# Get database password from environment and check
DB_PASSWORD = os.environ.get('DJANGO_DB_PASSWORD', None)
if DB_PASSWORD is None:
db_password = os.environ.get('DJANGO_DB_PASSWORD', None)
if db_password is None:
raise ImproperlyConfigured('Could not get database password from envvars.')
# Get database name from environment and check
db_name = os.environ.get('DJANGO_DB_NAME', None)
if db_name is None:
raise ImproperlyConfigured('Could not get database name from envvars.')
# Secret key for a Django installation
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', None)
if SECRET_KEY is None:
......@@ -29,10 +34,10 @@ TWILIO_AUTH_TOKEN = os.environ.get('DJANGO_TWILIO_AUTH_TOKEN', 'abcd')
# Database settings -----------------------------------------------------------
DATABASES = {
'default' : {
'NAME': 'gracedb',
'NAME': db_name,
'ENGINE': 'django.db.backends.mysql',
'USER': os.environ.get('DJANGO_DB_USER', 'gracedb'),
'PASSWORD': DB_PASSWORD,
'PASSWORD': db_password,
'HOST': os.environ.get('DJANGO_DB_HOST', ''),
'PORT': os.environ.get('DJANGO_DB_PORT', ''),
'OPTIONS': {
......
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