From 5853a260b7a6b77cbc495022f985059f7db3ed4d Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 14 May 2020 22:35:14 -0400 Subject: [PATCH 1/7] Updates sartography-workflow-lib --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7be706a..b9f5c17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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.162", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.162.tgz", + "integrity": "sha512-t3lssrs+p4BXbUge0ey7Df1ccbjr2xHna5YM1amx1PlKIl4NSfereFEwjb8PppAsX8woNJI4UPmO6twqfAariQ==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index 0789b5e..5a93ae9 100644 --- a/package.json +++ b/package.json @@ -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.162", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3" From d567497ef22c62c81b0c16d8a72381267e0e7fd7 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sat, 16 May 2020 14:14:53 -0400 Subject: [PATCH 2/7] Updates sartography-workflow-lib --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b9f5c17..00e83c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12291,9 +12291,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.162", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.162.tgz", - "integrity": "sha512-t3lssrs+p4BXbUge0ey7Df1ccbjr2xHna5YM1amx1PlKIl4NSfereFEwjb8PppAsX8woNJI4UPmO6twqfAariQ==" + "version": "0.0.164", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.164.tgz", + "integrity": "sha512-0sbIR8gkXfPOJOJzHQyzzo7mIS9W8bLiQW/pzp/RWATj0j+MGn9z6aPKQBs6PKUP0KMzAOXfXywkR3e3aPJSoA==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index 5a93ae9..cd2d9e8 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "^0.0.162", + "sartography-workflow-lib": "^0.0.164", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3" From 9d28a472a5d0fe953c24df429e94a7fd27863426 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sat, 16 May 2020 22:18:16 -0400 Subject: [PATCH 3/7] Runs nginx on port from environment variable --- Dockerfile | 7 +++++++ docker/substitute-env-variables.sh | 2 +- nginx.conf | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e64090e..77fd5d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,15 @@ 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 + +# Substitute environment variables in nginx configuration +CMD ["./entrypoint.sh", "/etc/nginx/conf.d/default.conf"] + +# Substitute environment variables in index.html ENTRYPOINT ["./entrypoint.sh", "/usr/share/nginx/html/index.html"] ### STAGE 3: Profit! ### diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh index ee28b93..438c144 100644 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -7,7 +7,7 @@ if [[ -z $1 ]]; then 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" +envsubst '\$PRODUCTION \$API_URL \$IRB_URL \$PORT0' < "$1" > "$1".tmp && mv "$1".tmp "$1" # Set DEBUG=true in order to log the replaced file if [ "$DEBUG" = true ] ; then diff --git a/nginx.conf b/nginx.conf index fd4472f..51982f5 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen $PORT0; location / { root /usr/share/nginx/html; From d6850f056c5d88a36eaab3624062e594260dc77b Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sat, 16 May 2020 22:59:05 -0400 Subject: [PATCH 4/7] Substitutes environment variables in multiple files --- Dockerfile | 7 ++----- docker/substitute-env-variables.sh | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) mode change 100644 => 100755 docker/substitute-env-variables.sh diff --git a/Dockerfile b/Dockerfile index 77fd5d0..0781b10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,11 +22,8 @@ COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf COPY ./docker/substitute-env-variables.sh ./entrypoint.sh RUN chmod +x ./entrypoint.sh -# Substitute environment variables in nginx configuration -CMD ["./entrypoint.sh", "/etc/nginx/conf.d/default.conf"] - -# Substitute environment variables in index.html -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;"] diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh old mode 100644 new mode 100755 index 438c144..73be4a6 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -1,18 +1,22 @@ #!/bin/bash -# The first parameter is the path to the file which should be substituted +# 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 \$PORT0' < "$1" > "$1".tmp && mv "$1".tmp "$1" +env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0' +for i 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" -# Set DEBUG=true in order to log the replaced file -if [ "$DEBUG" = true ] ; then - exec cat $1 -fi + # Set DEBUG=true in order to log the replaced file + if [ "$DEBUG" = true ] ; then + exec cat $i + fi +done # Execute all other commands with parameters exec "${@:2}" From 999eb18fcc596e6ebf6a88432f8ad81cc2a41dcd Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sun, 17 May 2020 09:50:00 -0400 Subject: [PATCH 5/7] Removes debug thing, which was causing it to crash --- docker/substitute-env-variables.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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}" From 55f37eb805c4fa71415eb17f552f58ab8b61797a Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Sun, 17 May 2020 14:25:42 -0400 Subject: [PATCH 6/7] Prints out environment variables --- docker/substitute-env-variables.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh index bd3d9cb..b6b187b 100755 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -20,6 +20,11 @@ do 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}" From 18e76131ba7b3bf6f9573f2b92bd41109bbe5dbb Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 18 May 2020 13:23:32 -0400 Subject: [PATCH 7/7] Updates sartography-workflow-lib --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00e83c0..2854c01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12291,9 +12291,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.164", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.164.tgz", - "integrity": "sha512-0sbIR8gkXfPOJOJzHQyzzo7mIS9W8bLiQW/pzp/RWATj0j+MGn9z6aPKQBs6PKUP0KMzAOXfXywkR3e3aPJSoA==" + "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", diff --git a/package.json b/package.json index cd2d9e8..7e1abb2 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "^0.0.164", + "sartography-workflow-lib": "^0.0.167", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3"