Skip to content

Commit f9a5cc5

Browse files
authored
Merge pull request #137 from aws-samples/wangzt-dev
env bug fix
2 parents 24bf115 + f4b8c37 commit f9a5cc5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

report-front-end/docker-entry.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
# Read variable names from the .env file
44
env_file="/.env"
55
vars="VITE_COGNITO_REGION
6-
VITE_COGNITO_USER_POOL_ID
76
VITE_COGNITO_USER_POOL_WEB_CLIENT_ID
7+
VITE_COGNITO_USER_POOL_ID
88
VITE_BACKEND_URL
99
VITE_WEBSOCKET_URL"
1010

1111
# Iterate through .js files in /usr/share/nginx/html and replace variables
12-
find "/usr/share/nginx/html" -type f -name "*.js" | while read file; do
12+
find "/usr/share/nginx/html" -type f -name "*.js" | while read -r file; do
1313
for var in $vars; do
1414
placeholder="PLACEHOLDER_$var"
15-
value=$(printenv $var)
16-
echo "Replacing $placeholder with $value"
17-
sed -i "s/$placeholder/$value/g" $file
15+
value=$(eval "echo \$$var")
16+
17+
# Escape special characters in the value for use in sed
18+
escaped_value=$(printf '%s\n' "$value" | sed -e 's/[\/&]/\\&/g')
19+
20+
echo "Replacing $placeholder with $escaped_value in $file"
21+
sed -i "s/$placeholder/$escaped_value/g" "$file"
1822
done
1923
done
2024

21-
exec "$@"
25+
exec "$@"

0 commit comments

Comments
 (0)