dh docker: first migrate, then config

This commit is contained in:
pedro 2024-11-27 01:08:22 +01:00
parent 09f6cd2e68
commit 6e7cb0bf84

View file

@ -129,15 +129,18 @@ config_phase() {
if [ "${DPP_MODULE}" = 'y' ]; then if [ "${DPP_MODULE}" = 'y' ]; then
# 12, 13, 14 # 12, 13, 14
config_dpp_part1 config_dpp_part1
# copy dlt/dpp snapshots
cp example/dpp-snapshots/*.json example/snapshots/
fi fi
# TODO fix wrong syntax
# non DL user (only for the inventory) # non DL user (only for the inventory)
# ./manage.py adduser user2@dhub.com ${INIT_PASSWD} ./manage.py add_institution "${INIT_ORG}"
# TODO: one error on add_user, and you don't add user anymore
./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}"
# # 15. Add inventory snapshots for user "${INIT_USER}". # # 15. Add inventory snapshots for user "${INIT_USER}".
if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then if [ "${DEMO:-}" = 'true' ]; then
cp /mnt/snapshots/*.json example/snapshots/
/usr/bin/time ./manage.py up_snapshots "${INIT_USER}" /usr/bin/time ./manage.py up_snapshots "${INIT_USER}"
fi fi
@ -172,13 +175,7 @@ deploy() {
# 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
echo "INFO detected NEW deployment" echo "INFO detected NEW deployment"
./manage.py migrate ./manage.py migrate
./manage.py add_institution "${INIT_ORG}" config_phase
# TODO: one error on add_user, and you don't add user anymore
./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}"
if [ "${DEMO:-}" = 'true' ]; then
./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
fi
fi fi
} }
@ -207,7 +204,6 @@ main() {
program_dir='/opt/devicehub-django' program_dir='/opt/devicehub-django'
cd "${program_dir}" cd "${program_dir}"
gen_env_vars gen_env_vars
config_phase
deploy deploy
runserver runserver
} }