-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the Lagoon url resolving to the application build step
Because the LAGOON_ROUTES env variable is not accesible client side, we do the url processing before the build step and turn them into NEXT_PUBLIC_ variables.
- Loading branch information
Showing
9 changed files
with
35 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
#!/bin/sh | ||
getLagoonUrl() { | ||
local type=$1 | ||
|
||
# if [ $LAGOON_ENVIRONMENT_TYPE == "production" ]; then | ||
# cd /app | ||
# npm run start | ||
# else | ||
# cd /app | ||
# npm run dev | ||
# fi | ||
for route in ${LAGOON_ROUTES//,/ }; do | ||
if echo "$route" | grep -q "$type"; then | ||
echo "$route" | ||
return | ||
fi | ||
done | ||
} | ||
|
||
cd /app | ||
# 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 | ||
|
||
# Make sure the DPL CMS graphql schema endpoint is set in application | ||
cms_url=$(getLagoonUrl nginx) | ||
|
||
echo "!! cms url: $cms_url" | ||
if [ -z "$cms_url" ]; then | ||
echo "Error: Unable to determine CMS URL" | ||
exit 1 | ||
fi | ||
|
||
# Set the environment variables. | ||
# These ones are varying from environment to environment. | ||
export NEXT_PUBLIC_APP_URL="$app_url" | ||
export NEXT_PUBLIC_GRAPHQL_SCHEMA_ENDPOINT_DPL_CMS="$cms_url/graphql" | ||
|
||
# Go to the app directory if it doesn't exist then never mind. | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.