Skip to content

Commit

Permalink
Update entrypoint script to read VITE environment variables and impro…
Browse files Browse the repository at this point in the history
…ve variable handling
  • Loading branch information
remyvdwereld committed Jan 13, 2025
1 parent d68d07b commit e511fd8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

set -x

# This script will read all the env variables prefixed with REACT_APP on start of the container and write them to the env.js file
# This script will read all the env variables prefixed with VITE_ on start of the container and write them to the env.js file
# The code uses this file as the env variables instead of the .env files
# This makes it possible to use a single build artifact/image for multiple environment

echo "window.env = {" >> /var/www/application/config/env.js

for var in $(printenv); do
if [[ $var == VITE* ]]; then
key=$(echo $var | cut -f1 -d=)
value=$(echo $var | cut -f2 -d=)
echo "window.env = {" > /var/www/application/config/env.js

printenv | while IFS='=' read -r key value; do
if [[ $key == VITE* ]]; then
echo " \"$key\": \"$value\"," >> /var/www/application/config/env.js
fi
done
Expand Down

0 comments on commit e511fd8

Please sign in to comment.