docker: put init data as part of dev deployment
use django default env vars on a production deployment
This commit is contained in:
parent
81a6398f02
commit
e2e74926ca
|
@ -15,9 +15,6 @@
|
|||
|
||||
IDHUB_TIME_ZONE='Europe/Madrid'
|
||||
#IDHUB_SECRET_KEY='uncomment-it-and-fill-this'
|
||||
IDHUB_USER='admin'
|
||||
IDHUB_PASSWD='admin'
|
||||
IDHUB_EMAIL='admin@example.org'
|
||||
# enable dev flags when DEVELOPMENT deployment
|
||||
IDHUB_DEPLOYMENT='DEVELOPMENT'
|
||||
# adapt to your domain in a production/reverse proxy env
|
||||
|
@ -31,3 +28,9 @@ IDHUB_EMAIL_HOST_PASSWORD="smtp_passwd"
|
|||
IDHUB_EMAIL_PORT=25
|
||||
IDHUB_EMAIL_USE_TLS=True
|
||||
IDHUB_EMAIL_BACKEND="django.core.mail.backends.smtp.EmailBackend"
|
||||
|
||||
# replace with production data
|
||||
# this is used when IDHUB_DEPLOYMENT is not equal to DEVELOPMENT
|
||||
IDHUB_USER='admin'
|
||||
IDHUB_PASSWD='admin'
|
||||
IDHUB_EMAIL='admin@example.org'
|
||||
|
|
|
@ -5,6 +5,7 @@ services:
|
|||
init: true
|
||||
image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/idhub:latest
|
||||
environment:
|
||||
- DEPLOYMENT=${IDHUB_DEPLOYMENT}
|
||||
- SECRET_KEY=${IDHUB_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd}
|
||||
- ALLOWED_HOSTS=${IDHUB_ALLOWED_HOSTS:-*}
|
||||
- STATIC_ROOT=${IDHUB_STATIC_ROOT:-/static/}
|
||||
|
@ -13,7 +14,6 @@ services:
|
|||
- DJANGO_SUPERUSER_USERNAME=${IDHUB_USER}
|
||||
- DJANGO_SUPERUSER_PASSWORD=${IDHUB_PASSWD}
|
||||
- DJANGO_SUPERUSER_EMAIL=${IDHUB_EMAIL}
|
||||
- DEPLOYMENT=${IDHUB_DEPLOYMENT}
|
||||
- CSRF_TRUSTED_ORIGINS=${IDHUB_CSRF_TRUSTED_ORIGINS}
|
||||
- DEFAULT_FROM_EMAIL=${IDHUB_DEFAULT_FROM_EMAIL}
|
||||
- EMAIL_HOST=${IDHUB_EMAIL_HOST}
|
||||
|
|
|
@ -8,23 +8,25 @@ main() {
|
|||
# go to the same path as the script
|
||||
cd "$(dirname ${0})"
|
||||
|
||||
# enable dev flags when DEVELOPMENT deployment
|
||||
if [ "${DEPLOYMENT}" = 'DEVELOPMENT' ]; then
|
||||
export DEBUG=True
|
||||
export DEVELOPMENT=True
|
||||
fi
|
||||
|
||||
# move the migrate thing in docker entrypoint
|
||||
# inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc
|
||||
./manage.py migrate
|
||||
|
||||
printf "creating initial Datas\n" >&2
|
||||
./manage.py initial_datas
|
||||
#./manage.py collectstatic
|
||||
# enable dev flags when DEVELOPMENT deployment
|
||||
if [ "${DEPLOYMENT}" = 'DEVELOPMENT' ]; then
|
||||
export DEBUG=True
|
||||
export DEVELOPMENT=True
|
||||
|
||||
printf "This is DEVELOPMENT DEPLOYMENT: including demo hardcoded data\n creating initial Datas\n" >&2
|
||||
./manage.py initial_datas
|
||||
|
||||
else
|
||||
printf "creating superuser \n user: ${DJANGO_SUPERUSER_USERNAME}\n password: ${DJANGO_SUPERUSER_PASSWORD}\n email: ${DJANGO_SUPERUSER_EMAIL}\n" >&2
|
||||
# thanks https://stackoverflow.com/questions/6244382/how-to-automate-createsuperuser-on-django/59467533#59467533
|
||||
## thanks https://stackoverflow.com/questions/6244382/how-to-automate-createsuperuser-on-django/59467533#59467533
|
||||
./manage.py createsuperuser --no-input
|
||||
fi
|
||||
|
||||
#./manage.py collectstatic
|
||||
|
||||
./manage.py runserver 0.0.0.0:${PORT}
|
||||
}
|
||||
|
|
Reference in New Issue