dh docker entrypoint: use appropriate new env vars

This commit is contained in:
pedro 2024-11-27 00:11:44 +01:00
parent 9863a59911
commit 69bc95c0cd

View file

@ -28,6 +28,11 @@ wait_for_dpp_shared() {
# 3. Generate an environment .env file. # 3. Generate an environment .env file.
# TODO cargar via shared # TODO cargar via shared
gen_env_vars() { gen_env_vars() {
INIT_ORG="${INIT_ORG:-example-org}"
INIT_USER="${INIT_USER:-user@example.org}"
INIT_PASSWD="${INIT_PASSWD:-1234}"
ADMIN='True'
PREDEFINED_TOKEN="${PREDEFINED_TOKEN:-}"
# specific dpp env vars # specific dpp env vars
if [ "${DPP_MODULE}" = 'y' ]; then if [ "${DPP_MODULE}" = 'y' ]; then
# docker situation # docker situation
@ -98,7 +103,8 @@ config_dpp_part1() {
else else
# TODO when this runs more than one time per service, this is a problem, but for the docker-reset.sh workflow, that's fine # TODO when this runs more than one time per service, this is a problem, but for the docker-reset.sh workflow, that's fine
# TODO put this in already_configured # TODO put this in already_configured
./manage.py dlt_insert_members "${DEVICEHUB_HOST}" # TODO hardcoded http proto and port
./manage.py dlt_insert_members "http://${DOMAIN}:8000"
fi fi
# 13. Do a rsync api resolve # 13. Do a rsync api resolve
@ -108,8 +114,8 @@ config_dpp_part1() {
DATASET_FILE='/tmp/dataset.json' DATASET_FILE='/tmp/dataset.json'
cat > "${DATASET_FILE}" <<END cat > "${DATASET_FILE}" <<END
{ {
"email": "${EMAIL_DEMO}", "email": "${INIT_USER}",
"password": "${PASSWORD_DEMO}", "password": "${INIT_PASSWD}",
"api_token": "${API_DLT_TOKEN}" "api_token": "${API_DLT_TOKEN}"
} }
END END
@ -127,12 +133,12 @@ config_phase() {
# TODO fix wrong syntax # TODO fix wrong syntax
# non DL user (only for the inventory) # non DL user (only for the inventory)
# ./manage.py adduser user2@dhub.com ${PASSWORD_DEMO} # ./manage.py adduser user2@dhub.com ${INIT_PASSWD}
# # 15. Add inventory snapshots for user "${EMAIL_DEMO}". # # 15. Add inventory snapshots for user "${INIT_USER}".
if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then if [ "${IMPORT_SNAPSHOTS}" = 'y' ]; then
cp /mnt/snapshots/*.json example/snapshots/ cp /mnt/snapshots/*.json example/snapshots/
/usr/bin/time ./manage.py up_snapshots "${EMAIL_DEMO}" ${PASSWORD_DEMO} /usr/bin/time ./manage.py up_snapshots "${INIT_USER}"
fi fi
# remain next command as the last operation for this if conditional # remain next command as the last operation for this if conditional
@ -166,11 +172,6 @@ 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
INIT_ORG="${INIT_ORG:-example-org}"
INIT_USER="${INIT_USER:-user@example.org}"
INIT_PASSWD="${INIT_PASSWD:-1234}"
ADMIN='True'
PREDEFINED_TOKEN="${PREDEFINED_TOKEN:-}"
./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
./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}" ./manage.py add_user "${INIT_ORG}" "${INIT_USER}" "${INIT_PASSWD}" "${ADMIN}" "${PREDEFINED_TOKEN}"