From b0333092747a865471b97f1afa9741b86be33e0c Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Mon, 3 Feb 2025 02:48:14 -0300 Subject: [PATCH] changed deployment logic to config_phase --- docker/devicehub-django.entrypoint.sh | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/docker/devicehub-django.entrypoint.sh b/docker/devicehub-django.entrypoint.sh index 2f064e3..8f6f801 100644 --- a/docker/devicehub-django.entrypoint.sh +++ b/docker/devicehub-django.entrypoint.sh @@ -187,6 +187,7 @@ config_phase() { init_flagfile="${program_dir}/already_configured" if [ ! -f "${init_flagfile}" ]; then + echo "INFO: detected NEW deployment" # non DL user (only for the inventory) ./manage.py add_institution "${INIT_ORG}" # 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 touch "${init_flagfile}" + else + echo "INFO: detected PREVIOUS deployment" fi } @@ -229,22 +232,10 @@ deploy() { echo "DOMAIN: ${DOMAIN}" 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 - # 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 - config_phase - 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 + config_phase } runserver() {