diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh index 73be4a6..bd3d9cb 100755 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo 'Substituting environment variables...' + # The first parameter is a comma-delimited list of paths to files which should be substituted if [[ -z $1 ]]; then echo 'ERROR: No target files given.' @@ -7,16 +9,17 @@ if [[ -z $1 ]]; then fi env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0' -for i in $(echo $1 | sed "s/,/ /g") +for file_path in $(echo $1 | sed "s/,/ /g") do - # Replace strings in the given file(s) in env_list - envsubst "$env_list" < "$i" > "$i".tmp && mv "$i".tmp "$i" + echo "replacing $env_list in $file_path" - # Set DEBUG=true in order to log the replaced file - if [ "$DEBUG" = true ] ; then - exec cat $i - fi + # Replace strings in the given file(s) in env_list + envsubst "$env_list" < "$file_path" > "$file_path".tmp && mv "$file_path".tmp "$file_path" + + echo '...' done +echo 'Finished substituting environment variables.' + # Execute all other commands with parameters exec "${@:2}"