-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace all environment variables instead of only API_URL #5055
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e723ed8
Replace all environment variables instead of only API_URL
yasinuslu c812b62
Update docs
yasinuslu 76ec670
Make the script more robust
yasinuslu d779c94
Merge remote-tracking branch 'upstream/main' into update-replace-url
yasinuslu 89598a5
Update documentation of changeable env vars
yasinuslu 71c5b75
Merge branch 'main' into update-replace-url
poulch 5fb54fc
Merge branch 'main' into update-replace-url
yasinuslu 3e1fa9c
Create brown-carrots-search.md
poulch 33354ad
Merge branch 'main' into update-replace-url
poulch 88bb43d
Merge branch 'main' into update-replace-url
poulch 9cf418e
Rename env var script
yasinuslu 922546d
Merge branch 'main' into update-replace-url
poulch ff0c53c
Merge branch 'main' into update-replace-url
poulch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Replaces the API_URL from the bundle's index.html file with the $API_URL env var. | ||
# Replaces environment variables in the bundle's index.html file with their respective values. | ||
# This script is automatically picked up by the nginx entrypoint on startup. | ||
|
||
set -e | ||
|
||
INDEX_BUNDLE_PATH="/app/dashboard/index.html" | ||
|
||
if [ -z "${API_URL}" ]; then | ||
echo "No API_URL provided, using defaults." | ||
else | ||
echo "Setting API_URL to: $API_URL" | ||
# Function to replace environment variables | ||
replace_env_var() { | ||
var_name=$1 | ||
var_value=$(eval echo \$$var_name) | ||
if [ -n "$var_value" ]; then | ||
echo "Setting $var_name to: $var_value" | ||
sed -i "s#$var_name:.*#$var_name: \"$var_value\",#" "$INDEX_BUNDLE_PATH" | ||
else | ||
echo "No $var_name provided, using defaults." | ||
fi | ||
} | ||
|
||
sed -i "s#API_URL:.*#API_URL: \"$API_URL\",#" "$INDEX_BUNDLE_PATH" | ||
fi | ||
# Replace each environment variable | ||
replace_env_var "APP_MOUNT_URI" | ||
replace_env_var "APPS_MARKETPLACE_API_URL" | ||
replace_env_var "APPS_TUNNEL_URL_KEYWORDS" | ||
replace_env_var "STATIC_URL" | ||
replace_env_var "API_URL" | ||
|
||
echo "Environment variable replacement complete." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job - works as it should - can you change the filename to
replace-env-vars
instead ofreplace-api-url.sh
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course