From 44c378c82af07465bb667089ba1c3bd3c11802a7 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 23 Apr 2024 22:33:15 -0400 Subject: [PATCH] refactor: provide entrypoint.sh Closes #223 --- entrypoint.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..24b79f9e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +for command in "$@"; do + if [ "$command" = "initialize" ]; then + TANK_CALLBACK_BASE_URL=${TANK_CALLBACK_BASE_URL:-${AURA_PROTO}://${AURA_HOST}/tank} + DASHBOARD_CALLBACK_BASE_URL=${DASHBOARD_CALLBACK_BASE_URL:-${AURA_PROTO}://${AURA_HOST}} + + poetry run ./manage.py migrate --no-input + poetry run ./manage.py collectstatic --no-input + poetry run ./manage.py createsuperuser --no-input + poetry run ./manage.py create_oidc_client dashboard public --client-id "${DASHBOARD_OIDC_CLIENT_ID}" --client-secret "${DASHBOARD_OIDC_CLIENT_SECRET}" -r "id_token token" -u "${DASHBOARD_CALLBACK_BASE_URL}/oidc_callback.html" -u "${DASHBOARD_CALLBACK_BASE_URL}/oidc_callback_silentRenew.html" -p "${DASHBOARD_CALLBACK_BASE_URL}" -p "${DASHBOARD_CALLBACK_BASE_URL}/" + poetry run ./manage.py create_oidc_client tank confidential --client-id "${TANK_OIDC_CLIENT_ID}" --client-secret "${TANK_OIDC_CLIENT_SECRET}" -r "code" -u "${TANK_CALLBACK_BASE_URL}/tank/auth/oidc/callback" + poetry run ./manage.py addpermissions + poetry run ./manage.py creatersakey + fi + + # FIXME: these should be in the initialization or execute inside the running container + if [ "$command" = "loaddata.custom" ]; then + # from the docker-compose volume + poetry run ./manage.py loaddata fixtures/custom/*.json + elif [ "$command" = "loaddata.sample" ]; then + # from the steering Docker image + poetry run ./manage.py loaddata fixtures/sample/*.json + fi + + # start the application + if [ "$command" = "run.prod" ]; then + poetry run ./manage.py migrate --no-input + poetry run ./manage.py collectstatic --no-input + poetry run gunicorn --bind 0.0.0.0:8000 --workers "$(nproc)" steering.wsgi + elif [ "$command" = "run.dev" ]; then + poetry run ./manage.py migrate --no-input + poetry run ./manage.py collectstatic --no-input + poetry run ./manage.py runserver 0.0.0.0:8000 + fi +done -- GitLab