From 14946200c4534d45c6a34f40e421b186ebd61f8e Mon Sep 17 00:00:00 2001 From: Eric Bram <61522167+sei-ebram@users.noreply.github.com> Date: Thu, 22 Jul 2021 13:28:29 -0400 Subject: [PATCH] Switch from entrypoint to cmd to allow overriding (#249) - Add a script that copies an environment variable `SETTINGS` to the `settings.env.json` file for use as appsettings - Update Dockerfile to include the script above - Change the permissions of the `config` directory so that the startup script can write the `settings.env.json` file --- Dockerfile | 11 +++++++++-- nginx-basehref.sh => scripts/nginx-basehref.sh | 0 scripts/settings-from-env.sh | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) rename nginx-basehref.sh => scripts/nginx-basehref.sh (100%) create mode 100644 scripts/settings-from-env.sh diff --git a/Dockerfile b/Dockerfile index dc3a113..39d050d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,14 +21,21 @@ RUN $(npm bin)/ng build --configuration production FROM nginxinc/nginx-unprivileged:stable-alpine +# Clear all original files USER root RUN rm -rf /usr/share/nginx/html/* USER nginx COPY default.conf /etc/nginx/conf.d/default.conf -COPY nginx-basehref.sh /docker-entrypoint.d/90-basehref.sh +COPY scripts/settings-from-env.sh /usr/local/bin +COPY scripts/nginx-basehref.sh /docker-entrypoint.d/90-basehref.sh COPY --from=builder /ng-app/dist /usr/share/nginx/html +USER root +RUN chmod 755 /usr/local/bin/settings-from-env.sh && \ + chown nginx:nginx /usr/share/nginx/html/assets/config +USER nginx + EXPOSE 8080 -ENTRYPOINT ["nginx", "-g", "daemon off;"] +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx-basehref.sh b/scripts/nginx-basehref.sh similarity index 100% rename from nginx-basehref.sh rename to scripts/nginx-basehref.sh diff --git a/scripts/settings-from-env.sh b/scripts/settings-from-env.sh new file mode 100644 index 0000000..1894432 --- /dev/null +++ b/scripts/settings-from-env.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +echo $SETTINGS > /usr/share/nginx/html/assets/config/settings.env.json +nginx -g "daemon off;" \ No newline at end of file