From f6fac1d0fa43e5e6dbfa3b433a8e1ad38ce06ba1 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 18 May 2020 22:36:13 -0400 Subject: [PATCH 1/3] Trying nginx:alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0781b10..93d0038 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN npm install && \ npm run build:$build_config ### STAGE 2: Run ### -FROM nginx +FROM nginx:alpine COPY --from=builder /crc-bpmn/dist/* /usr/share/nginx/html/ COPY --from=builder /crc-bpmn/nginx.conf /etc/nginx/conf.d/default.conf From 273f8c67e0f9a69a894d6a2a7fb14b91301f20fc Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 18 May 2020 23:00:35 -0400 Subject: [PATCH 2/3] Going back to non-alpine nginx --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 93d0038..0781b10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN npm install && \ npm run build:$build_config ### STAGE 2: Run ### -FROM nginx:alpine +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 From 637418e84068929bf9b698d7ed73864187b3f065 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Tue, 19 May 2020 22:20:03 -0400 Subject: [PATCH 3/3] Refactors environment variable substitution script --- Dockerfile | 2 +- docker/substitute-env-variables.sh | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0781b10..89030b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ COPY ./docker/substitute-env-variables.sh ./entrypoint.sh RUN chmod +x ./entrypoint.sh # 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! ### CMD ["nginx", "-g", "daemon off;"] diff --git a/docker/substitute-env-variables.sh b/docker/substitute-env-variables.sh index b6b187b..3a191b8 100755 --- a/docker/substitute-env-variables.sh +++ b/docker/substitute-env-variables.sh @@ -8,8 +8,15 @@ if [[ -z $1 ]]; then exit 1 fi -env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0' -for file_path in $(echo $1 | sed "s/,/ /g") +# The second parameter is a comma-delimited list of environment variable names +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 echo "replacing $env_list in $file_path" @@ -20,11 +27,10 @@ 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" +for env_var in ${2//,/ } +do + echo "$env_var = ${!env_var}" +done # Execute all other commands with parameters -exec "${@:2}" +exec "${@:3}"