From 8b4d1f51f6a1336a90548706e4b2bd5414b5ac6f Mon Sep 17 00:00:00 2001 From: pedro Date: Fri, 22 Nov 2024 12:07:25 +0100 Subject: [PATCH] docker devicehub-django entrypoint --- docker/devicehub-django.entrypoint.sh | 152 ++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/docker/devicehub-django.entrypoint.sh b/docker/devicehub-django.entrypoint.sh index fb057f9..61967f1 100644 --- a/docker/devicehub-django.entrypoint.sh +++ b/docker/devicehub-django.entrypoint.sh @@ -5,6 +5,156 @@ set -u # DEBUG set -x +# TODO there is a conflict between two shared vars +# 1. from the original docker compose devicehub-teal +# 2. from the new docker compose that integrates all dpp services +wait_for_dpp_shared() { + while true; do + # specially ensure VERAMO_API_CRED_FILE is not empty, + # it takes some time to get data in + OPERATOR_TOKEN_FILE='operator-token.txt' + if [ -f "/shared/${OPERATOR_TOKEN_FILE}" ] && \ + [ -f "/shared/create_user_operator_finished" ]; then + sleep 5 + echo "Files ready to process." + break + else + echo "Waiting for file in shared: ${OPERATOR_TOKEN_FILE}" + sleep 5 + fi + done +} + +# 3. Generate an environment .env file. +# TODO cargar via shared +gen_env_vars() { + # specific dpp env vars + if [ "${DPP_MODULE}" = 'y' ]; then + # docker situation + if [ -d "${DPP_SHARED:-}" ]; then + wait_for_dpp_shared + export API_DLT='http://api_connector:3010' + export API_DLT_TOKEN="$(cat "/shared/${OPERATOR_TOKEN_FILE}")" + export API_RESOLVER='http://id_index_api:3012' + # TODO hardcoded + export ID_FEDERATED='DH1' + # .env situation + else + dpp_env_vars="$(cat < .env < "${DATASET_FILE}" <