From 3a46125263ade206708353f814ef1a9b9219a5b3 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Wed, 4 Dec 2024 09:14:46 +0100 Subject: [PATCH] Trying to move var exporting to start file --- lagoon/set-env-variables.sh | 20 ++++++++--------- lagoon/start.sh | 44 +++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lagoon/set-env-variables.sh b/lagoon/set-env-variables.sh index d0a73bd..bc6c2e8 100755 --- a/lagoon/set-env-variables.sh +++ b/lagoon/set-env-variables.sh @@ -1,14 +1,13 @@ - getLagoonUrl() { - local type=$1 - IFS=',' read -r -a routes <<< "$LAGOON_ROUTES" - for route in "${routes[@]}"; do - if [[ $route == *"$type"* ]]; then - echo "$route" - return - fi - done - } + local type=$1 + + for route in ${LAGOON_ROUTES//,/ }; do + if echo "$route" | grep -q "$type"; then + echo "$route" + return + fi + done +} # Make sure app.url is set in application app_url=$(getLagoonUrl node) @@ -24,6 +23,5 @@ if [ -z "$cms_url" ]; then exit 1 fi - export NEXT_PUBLIC_APP_URL="$app_url" export NEXT_PUBLIC_GRAPHQL_SCHEMA_ENDPOINT_DPL_CMS="$cms_url/graphql" diff --git a/lagoon/start.sh b/lagoon/start.sh index f9ee866..a3a7038 100755 --- a/lagoon/start.sh +++ b/lagoon/start.sh @@ -1,19 +1,39 @@ -#!/bin/sh +# source /app/lagoon/set-env-variables.sh -# if [ $LAGOON_ENVIRONMENT_TYPE == "production" ]; then -# cd /app -# npm run start -# else -# cd /app -# npm run dev -# fi +getLagoonUrl() { + local type=$1 -source /app/lagoon/set-env-variables.sh + for route in ${LAGOON_ROUTES//,/ }; do + if echo "$route" | grep -q "$type"; then + echo "$route" + return + fi + done +} -echo "07:06" +# Make sure app.url is set in application +app_url=$(getLagoonUrl node) +if [ -z "$app_url" ]; then + echo "Error: Unable to determine app URL" + exit 1 +fi -cd /app +# Make sure the DPL CMS graphql schema endpoint is set in application +cms_url=$(getLagoonUrl nginx) +if [ -z "$cms_url" ]; then + echo "Error: Unable to determine CMS URL" + exit 1 +fi + +export NEXT_PUBLIC_APP_URL="$app_url" +export NEXT_PUBLIC_GRAPHQL_SCHEMA_ENDPOINT_DPL_CMS="$cms_url/graphql" + +printenv + +echo "21:09" + +cd /app || exit 1 # TODO: Remember to adjust the following line before deploying to production. # Using `yarn start:with-server-source-maps` is probably adding a performance overhead. yarn build && yarn start:with-server-source-maps -exit 0; +exit 0