From 9007c5f2bf7098f826da38947875bca85361d51d Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 27 Jun 2024 13:28:13 -0500 Subject: [PATCH 1/3] Replace sed with dedicated app.constants.template --- .dockerignore | 1 + src/Container/Dockerfile | 10 ++-------- src/Container/app.constants.template | 7 +++++++ 3 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 src/Container/app.constants.template diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..7990a5adc --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +app.constants.js \ No newline at end of file diff --git a/src/Container/Dockerfile b/src/Container/Dockerfile index 61176cb53..ee73aab35 100644 --- a/src/Container/Dockerfile +++ b/src/Container/Dockerfile @@ -23,16 +23,10 @@ LABEL org.opencontainers.image.title="ServicePulse" \ ENV SERVICECONTROL_URL="http://localhost:33333/api/" ENV MONITORING_URLS="['http://localhost:33633/']" ENV DEFAULT_ROUTE="/dashboard" +ENV SHOW_PENDING_RETRY="false" COPY /src/ServicePulse.Host/app /usr/share/nginx/html - -RUN mv /usr/share/nginx/html/js/app.constants.js /usr/share/nginx/html/js/app.constants.template &&\ - sed -i \ - -e "s,http://localhost:33333/api/,\$SERVICECONTROL_URL,g" \ - -e "s,\['http://localhost:33633/'\],\$MONITORING_URLS,g" \ - -e "s,/dashboard,\$DEFAULT_ROUTE,g" \ - /usr/share/nginx/html/js/app.constants.template - +ADD /src/Container/app.constants.template /usr/share/nginx/html/js/app.constants.template ADD /src/Container/nginx.conf /etc/nginx/ ADD --chown=root:root --chmod=755 /src/Container/updateconstants.sh /docker-entrypoint.d/40-update-servicepulse-constants.sh diff --git a/src/Container/app.constants.template b/src/Container/app.constants.template new file mode 100644 index 000000000..a8da7d905 --- /dev/null +++ b/src/Container/app.constants.template @@ -0,0 +1,7 @@ +window.defaultConfig = { + default_route: '$DEFAULT_ROUTE', + version: '1.2.0', + service_control_url: '$SERVICECONTROL_URL', + monitoring_urls: $MONITORING_URLS, + showPendingRetry: $SHOW_PENDING_RETRY, +}; From 04ffc2439fbbf4c1c1f0a62aee7848c586e1ee57 Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 27 Jun 2024 14:00:55 -0500 Subject: [PATCH 2/3] Use sed for version --- .dockerignore | 2 +- src/Container/Dockerfile | 3 +++ src/Container/README.md | 1 + src/Container/app.constants.template | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7990a5adc..fc15e27b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1 @@ -app.constants.js \ No newline at end of file +**/app.constants.js \ No newline at end of file diff --git a/src/Container/Dockerfile b/src/Container/Dockerfile index ee73aab35..b9ac402d4 100644 --- a/src/Container/Dockerfile +++ b/src/Container/Dockerfile @@ -27,6 +27,9 @@ ENV SHOW_PENDING_RETRY="false" COPY /src/ServicePulse.Host/app /usr/share/nginx/html ADD /src/Container/app.constants.template /usr/share/nginx/html/js/app.constants.template + +RUN sed -i -e "s,__VERSION__,$VERSION,g" /usr/share/nginx/html/js/app.constants.template + ADD /src/Container/nginx.conf /etc/nginx/ ADD --chown=root:root --chmod=755 /src/Container/updateconstants.sh /docker-entrypoint.d/40-update-servicepulse-constants.sh diff --git a/src/Container/README.md b/src/Container/README.md index 21d4a74f2..118f280e9 100644 --- a/src/Container/README.md +++ b/src/Container/README.md @@ -15,6 +15,7 @@ docker run -p 9090:90 particular/servicepulse:latest - **`SERVICECONTROL_URL`**: _Default_: `http://localhost:33333/api/`. The url to your ServiceControl instance - **`MONITORING_URLS`**: _Default_: `['http://localhost:33633/']`. A JSON array of URLs to your monitoring instances - **`DEFAULT_ROUTE`**: _Default_: `/dashboard`. The default page that should be displayed when visiting the site +- **`SHOW_PENDING_RETRY`** _Default_: `false`. Set to `true` to show details of pending retries It may be desireable to run the ServiceControl services in an isolated network. When doing so ServicePulse must be configured to connect to those services using environment variables: diff --git a/src/Container/app.constants.template b/src/Container/app.constants.template index a8da7d905..de718e99d 100644 --- a/src/Container/app.constants.template +++ b/src/Container/app.constants.template @@ -1,6 +1,6 @@ window.defaultConfig = { default_route: '$DEFAULT_ROUTE', - version: '1.2.0', + version: '__VERSION__', service_control_url: '$SERVICECONTROL_URL', monitoring_urls: $MONITORING_URLS, showPendingRetry: $SHOW_PENDING_RETRY, From fe7267f99583c25439921dbf272835f08922dbc6 Mon Sep 17 00:00:00 2001 From: David Boike Date: Thu, 27 Jun 2024 14:11:59 -0500 Subject: [PATCH 3/3] Fully specify dockerignore path --- .dockerignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index fc15e27b3..517732e79 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ -**/app.constants.js \ No newline at end of file +# Generated dynamically using a template to support environment variables +src/ServicePulse.Host/app/js/app.constants.js \ No newline at end of file