From 952f61ef8e35d084d17b09b3960c695b779b9ef0 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Tue, 30 Apr 2024 18:40:59 -0400
Subject: [PATCH] fix: remove initialize & loadfixtures from the entrypoint

---
 entrypoint.sh | 42 ++++++++----------------------------------
 1 file changed, 8 insertions(+), 34 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 24b79f9e..7298ff78 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,36 +1,10 @@
 #!/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
+poetry run ./manage.py migrate --no-input
+
+if [ "$1" = "run.prod" ]; then
+	# TODO: is there another way to pass `$(nproc)`?
+	poetry run gunicorn --bind 0.0.0.0:8000 --workers "$(nproc)" steering.wsgi
+elif [ "$1" = "run.dev" ]; then
+	poetry run ./manage.py runserver 0.0.0.0:8000
+fi
-- 
GitLab