Skip to content

Commit

Permalink
Trying to move var exporting to start file
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceo committed Dec 4, 2024
1 parent 57753c3 commit 3a46125
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
20 changes: 9 additions & 11 deletions lagoon/set-env-variables.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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"
44 changes: 32 additions & 12 deletions lagoon/start.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3a46125

Please sign in to comment.