Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IGWN Computing and Software
GraceDB
GraceDB Server
Commits
c29061a2
Commit
c29061a2
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Get DB name from environment for containerized version
parent
92056652
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+8
-13
8 additions, 13 deletions
Dockerfile
config/settings/container/base.py
+9
-4
9 additions, 4 deletions
config/settings/container/base.py
with
17 additions
and
17 deletions
Dockerfile
+
8
−
13
View file @
c29061a2
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
config/settings/container/base.py
+
9
−
4
View file @
c29061a2
...
...
@@ -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
'
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment