Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Jul 6, 2024
1 parent 164a611 commit 84acee7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 0 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ if [[ $PULL_SECRETS_FROM_VAULT -eq 1 ]]; then
echo "Secrets sourced"
fi

pwd

sleep 1999
/usr/share/nginx/html/injectEnv.sh

nginx -g "daemon off;"
11 changes: 5 additions & 6 deletions scripts/injectEnv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ source .env

NGINX_INDEX_FILE="/usr/share/nginx/html/index.html"

clientEnvVars=$(env | grep REACT_APP_)
clientEnvVars=$(echo $clientEnvVars | sed 's/=/":"/g')
clientEnvVars=$(echo $clientEnvVars | sed 's/^/"/g')
clientEnvVars=$(echo $clientEnvVars | sed 's/$/"/g')
clientEnvVars=$(echo $clientEnvVars | sed 's/ /,/g')
# Extract environment variables that start with REACT_APP_ and format them as JSON
clientEnvVars=$(env | grep '^REACT_APP_' | awk -F= '{print "\""$1"\":\""$2"\""}' | paste -sd, -)
clientEnvVars="{$clientEnvVars}"

sed -i "s/\"__ENV__\"/$clientEnvVars/g" $NGINX_INDEX_FILE
# Replace the placeholder with the formatted environment variables in the index file
sed -i "s@\"__ENV__\"@${clientEnvVars}@g" $NGINX_INDEX_FILE

0 comments on commit 84acee7

Please sign in to comment.