changed deployment logic to config_phase
This commit is contained in:
parent
48bea36e49
commit
b033309274
|
@ -187,6 +187,7 @@ config_phase() {
|
||||||
init_flagfile="${program_dir}/already_configured"
|
init_flagfile="${program_dir}/already_configured"
|
||||||
if [ ! -f "${init_flagfile}" ]; then
|
if [ ! -f "${init_flagfile}" ]; then
|
||||||
|
|
||||||
|
echo "INFO: detected NEW deployment"
|
||||||
# non DL user (only for the inventory)
|
# non DL user (only for the inventory)
|
||||||
./manage.py add_institution "${INIT_ORG}"
|
./manage.py add_institution "${INIT_ORG}"
|
||||||
# TODO: one error on add_user, and you don't add user anymore
|
# TODO: one error on add_user, and you don't add user anymore
|
||||||
|
@ -209,6 +210,8 @@ config_phase() {
|
||||||
|
|
||||||
# remain next command as the last operation for this if conditional
|
# remain next command as the last operation for this if conditional
|
||||||
touch "${init_flagfile}"
|
touch "${init_flagfile}"
|
||||||
|
else
|
||||||
|
echo "INFO: detected PREVIOUS deployment"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,22 +232,10 @@ deploy() {
|
||||||
echo "DOMAIN: ${DOMAIN}"
|
echo "DOMAIN: ${DOMAIN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#IMPORTANT: run python manage.py dumpdata --natural-foreign --natural-primary > sqlite3dump.json on root folder
|
|
||||||
# detect if exists a sqlite3 dump
|
|
||||||
if [ -f "${program_dir}/sqlite3dump.json" ]; then
|
|
||||||
echo "INFO: detected EXISTING sqlite3 deployment. Migrating to postgres"
|
|
||||||
./manage.py migrate
|
|
||||||
./manage.py loaddata ${program_dir}/sqlite3dump.json
|
|
||||||
rm "${program_dir}/sqlite3dump.json"
|
|
||||||
echo "INFO: Old sqlite data loaded successfully"
|
|
||||||
|
|
||||||
else
|
|
||||||
# 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
|
||||||
echo "INFO detected NEW deployment"
|
|
||||||
./manage.py migrate
|
./manage.py migrate
|
||||||
config_phase
|
config_phase
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runserver() {
|
runserver() {
|
||||||
|
|
Loading…
Reference in a new issue