docker: add entrypoint and add support for dynamic config
This commit is contained in:
parent
26f3a1881d
commit
8b06c2c6e9
3 changed files with 28 additions and 0 deletions
|
@ -27,3 +27,6 @@ COPY requirements.txt ./
|
|||
RUN LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install --no-cache-dir -r requirements.txt"
|
||||
|
||||
COPY ./ .
|
||||
COPY entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh" ]
|
||||
|
|
|
@ -777,3 +777,9 @@ if DEBUG:
|
|||
from .local import * # flake8: noqa
|
||||
else:
|
||||
from .prod import * # flake8: noqa
|
||||
|
||||
# Try to load dynamic configuration, if it exists
|
||||
try:
|
||||
from .dynamic import * # flake8: noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
19
entrypoint.sh
Normal file
19
entrypoint.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -uex
|
||||
|
||||
cd /usr/src/app/
|
||||
cat > dynamicweb/settings/dynamic.py <<EOF
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': '${POSTGRES_DB}',
|
||||
'USER': '${POSTGRES_USER}',
|
||||
'PASSWORD': '${POSTGRES_PASSWORD}',
|
||||
'HOST': '${POSTGRES_HOST}',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
exec "$@"
|
Loading…
Reference in a new issue