From 8fcd20f6095f4e8cf089c9facb63b6050c06ccf4 Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 27 Nov 2024 01:08:22 +0100 Subject: [PATCH] dh docker: first migrate, then config --- docker/devicehub-django.entrypoint.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/docker/devicehub-django.entrypoint.sh b/docker/devicehub-django.entrypoint.sh index c6736b8..889c76d 100644 --- a/docker/devicehub-django.entrypoint.sh +++ b/docker/devicehub-django.entrypoint.sh @@ -129,15 +129,18 @@ config_phase() { if [ "${DPP_MODULE}" = 'y' ]; then # 12, 13, 14 config_dpp_part1 + + # copy dlt/dpp snapshots + cp example/dpp-snapshots/*.json example/snapshots/ fi - # TODO fix wrong syntax # 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}". - if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then - cp /mnt/snapshots/*.json example/snapshots/ + if [ "${DEMO:-}" = 'true' ]; then /usr/bin/time ./manage.py up_snapshots "${INIT_USER}" fi @@ -172,13 +175,7 @@ deploy() { # 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 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}" - - if [ "${DEMO:-}" = 'true' ]; then - ./manage.py up_snapshots example/snapshots/ "${INIT_USER}" - fi + config_phase fi } @@ -207,7 +204,6 @@ main() { program_dir='/opt/devicehub-django' cd "${program_dir}" gen_env_vars - config_phase deploy runserver }