Merge branch 'dev' into rrt/dev

This commit is contained in:
Aaron Louie 2020-05-18 13:24:07 -04:00
commit 49bc64b0a5
5 changed files with 30 additions and 14 deletions

View File

@ -17,9 +17,13 @@ RUN npm install && \
FROM nginx
COPY --from=builder /crc-bpmn/dist/* /usr/share/nginx/html/
COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf
# Script for substituting environment variables
COPY ./docker/substitute-env-variables.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/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"]
### STAGE 3: Profit! ###
CMD ["nginx", "-g", "daemon off;"]

28
docker/substitute-env-variables.sh Normal file → Executable file
View File

@ -1,18 +1,30 @@
#!/bin/bash
# The first parameter is the path to the file which should be substituted
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 file given.'
echo 'ERROR: No target files given.'
exit 1
fi
# Replace strings in the given file that have the format ${ENV_VAR}
envsubst '\$PRODUCTION \$API_URL \$IRB_URL' < "$1" > "$1".tmp && mv "$1".tmp "$1"
env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0'
for file_path in $(echo $1 | sed "s/,/ /g")
do
echo "replacing $env_list in $file_path"
# Set DEBUG=true in order to log the replaced file
if [ "$DEBUG" = true ] ; then
exec cat $1
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.'
echo "PRODUCTION = $PRODUCTION"
echo "API_URL = $API_URL"
echo "IRB_URL = $IRB_URL"
echo "HOME_ROUTE = $HOME_ROUTE"
echo "PORT0 = $PORT0"
# Execute all other commands with parameters
exec "${@:2}"

View File

@ -1,5 +1,5 @@
server {
listen 80;
listen $PORT0;
location / {
root /usr/share/nginx/html;

6
package-lock.json generated
View File

@ -12291,9 +12291,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sartography-workflow-lib": {
"version": "0.0.159",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.159.tgz",
"integrity": "sha512-EkXmgoliJkBqsBrI/3N3GLNJmrVgwu4kekU8M6Z2E15+shRwmLH0vxFAWmW0JDG2JGcw7vOhPMb8iVlLlLcr7A=="
"version": "0.0.167",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.167.tgz",
"integrity": "sha512-Ju6VehVOj6yjAYOTEN2PtFbWUXB6LTldaf5GO8iW2lx20Z+TGnrK0Lvgh1hv3/F+7yUqpcZjJvO+ppYahpURRA=="
},
"sass": {
"version": "1.23.3",

View File

@ -52,7 +52,7 @@
"ngx-file-drop": "^8.0.8",
"ngx-markdown": "^9.0.0",
"rxjs": "~6.5.4",
"sartography-workflow-lib": "^0.0.159",
"sartography-workflow-lib": "^0.0.167",
"tslib": "^1.11.1",
"uuid": "^7.0.2",
"zone.js": "^0.10.3"