Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use app.constants.template file for container env customization #1901

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated dynamically using a template to support environment variables
src/ServicePulse.Host/app/js/app.constants.js
9 changes: 3 additions & 6 deletions src/Container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ 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
ADD /src/Container/app.constants.template /usr/share/nginx/html/js/app.constants.template

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
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
Expand Down
1 change: 1 addition & 0 deletions src/Container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 7 additions & 0 deletions src/Container/app.constants.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
window.defaultConfig = {
default_route: '$DEFAULT_ROUTE',
version: '__VERSION__',
service_control_url: '$SERVICECONTROL_URL',
monitoring_urls: $MONITORING_URLS,
showPendingRetry: $SHOW_PENDING_RETRY,
};