Merge pull request #29 from sartography/testing

Testing
This commit is contained in:
Aaron Louie 2020-05-20 10:03:12 -04:00 committed by GitHub
commit 70ae185fb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -23,7 +23,7 @@ COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh RUN chmod +x ./entrypoint.sh
# Substitute environment variables in nginx configuration and index.html # Substitute environment variables in nginx configuration and index.html
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html,/etc/nginx/conf.d/default.conf"] ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html,/etc/nginx/conf.d/default.conf", "PRODUCTION,API_URL,IRB_URL,HOME_ROUTE,PORT0"]
### STAGE 3: Profit! ### ### STAGE 3: Profit! ###
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

@ -8,8 +8,15 @@ if [[ -z $1 ]]; then
exit 1 exit 1
fi fi
env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0' # The second parameter is a comma-delimited list of environment variable names
for file_path in $(echo $1 | sed "s/,/ /g") if [[ -z $2 ]]; then
echo 'ERROR: No environment variables given.'
exit 1
fi
# Convert "VAR1,VAR2,VAR3,..." to "\$VAR1 \$VAR2 \$VAR3 ..."
env_list="\\\$${2//,/ \\\$}" # "\" and "$" are escaped as "\\" and "\$"
for file_path in ${1//,/ }
do do
echo "replacing $env_list in $file_path" echo "replacing $env_list in $file_path"
@ -20,11 +27,10 @@ do
done done
echo 'Finished substituting environment variables.' echo 'Finished substituting environment variables.'
echo "PRODUCTION = $PRODUCTION" for env_var in ${2//,/ }
echo "API_URL = $API_URL" do
echo "IRB_URL = $IRB_URL" echo "$env_var = ${!env_var}"
echo "HOME_ROUTE = $HOME_ROUTE" done
echo "PORT0 = $PORT0"
# Execute all other commands with parameters # Execute all other commands with parameters
exec "${@:2}" exec "${@:3}"