Compare commits

...

2 Commits

Author SHA1 Message Date
pedro e2e74926ca docker: put init data as part of dev deployment
use django default env vars on a production deployment
2023-11-16 17:03:19 +01:00
pedro 81a6398f02 idhub: add env vars for email credentials 2023-11-14 11:30:11 +01:00
3 changed files with 38 additions and 16 deletions

View File

@ -13,11 +13,24 @@
# IDHUB # IDHUB
#### ####
IDHUB_TIME_ZONE='Europe/Madrid'
#IDHUB_SECRET_KEY='uncomment-it-and-fill-this' #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 # enable dev flags when DEVELOPMENT deployment
IDHUB_DEPLOYMENT='DEVELOPMENT' IDHUB_DEPLOYMENT='DEVELOPMENT'
# adapt to your domain in a production/reverse proxy env # adapt to your domain in a production/reverse proxy env
IDHUB_CSRF_TRUSTED_ORIGINS='https://idhub.example.org' IDHUB_CSRF_TRUSTED_ORIGINS='https://idhub.example.org'
# fill this section with your email credentials
IDHUB_DEFAULT_FROM_EMAIL="user@example.org"
IDHUB_EMAIL_HOST="smtp.example.org"
IDHUB_EMAIL_HOST_USER="smtp_user"
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'

View File

@ -5,6 +5,7 @@ services:
init: true init: true
image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/idhub:latest image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/idhub:latest
environment: environment:
- DEPLOYMENT=${IDHUB_DEPLOYMENT}
- SECRET_KEY=${IDHUB_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd} - SECRET_KEY=${IDHUB_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd}
- ALLOWED_HOSTS=${IDHUB_ALLOWED_HOSTS:-*} - ALLOWED_HOSTS=${IDHUB_ALLOWED_HOSTS:-*}
- STATIC_ROOT=${IDHUB_STATIC_ROOT:-/static/} - STATIC_ROOT=${IDHUB_STATIC_ROOT:-/static/}
@ -13,7 +14,13 @@ services:
- DJANGO_SUPERUSER_USERNAME=${IDHUB_USER} - DJANGO_SUPERUSER_USERNAME=${IDHUB_USER}
- DJANGO_SUPERUSER_PASSWORD=${IDHUB_PASSWD} - DJANGO_SUPERUSER_PASSWORD=${IDHUB_PASSWD}
- DJANGO_SUPERUSER_EMAIL=${IDHUB_EMAIL} - DJANGO_SUPERUSER_EMAIL=${IDHUB_EMAIL}
- DEPLOYMENT=${IDHUB_DEPLOYMENT}
- CSRF_TRUSTED_ORIGINS=${IDHUB_CSRF_TRUSTED_ORIGINS} - CSRF_TRUSTED_ORIGINS=${IDHUB_CSRF_TRUSTED_ORIGINS}
- DEFAULT_FROM_EMAIL=${IDHUB_DEFAULT_FROM_EMAIL}
- EMAIL_HOST=${IDHUB_EMAIL_HOST}
- EMAIL_HOST_USER=${IDHUB_EMAIL_HOST_USER}
- EMAIL_HOST_PASSWORD=${IDHUB_EMAIL_HOST_PASSWORD}
- EMAIL_PORT=${IDHUB_EMAIL_PORT}
- EMAIL_USE_TLS=${IDHUB_EMAIL_USE_TLS}
- EMAIL_BACKEND=${IDHUB_EMAIL_BACKEND}
ports: ports:
- 7000:7000 - 7000:7000

View File

@ -8,23 +8,25 @@ main() {
# go to the same path as the script # go to the same path as the script
cd "$(dirname ${0})" 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 # move the migrate thing in docker entrypoint
# inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc # inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc
./manage.py migrate ./manage.py migrate
printf "creating initial Datas\n" >&2 # enable dev flags when DEVELOPMENT deployment
./manage.py initial_datas if [ "${DEPLOYMENT}" = 'DEVELOPMENT' ]; then
#./manage.py collectstatic 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 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 ./manage.py createsuperuser --no-input
fi
#./manage.py collectstatic
./manage.py runserver 0.0.0.0:${PORT} ./manage.py runserver 0.0.0.0:${PORT}
} }