From 8793d0fd5bd1ec7b1d5bf45ac1d6823801b8096d Mon Sep 17 00:00:00 2001 From: James Wilson Date: Sat, 14 Aug 2021 11:32:48 +0100 Subject: [PATCH] pass the feed URL via env var rather than config map so that standalone Docker usage is simplified --- README.md | 2 +- frontend/Dockerfile | 13 +++++++------ helm/templates/frontend-deployment.yaml | 7 ------- helm/templates/frontend-env-config.yaml | 10 ---------- helm/values.yaml | 5 ++++- 5 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 helm/templates/frontend-env-config.yaml diff --git a/README.md b/README.md index e23b043..e105df7 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ If you started the backend binaries with their default arguments, you can connec polkadot --dev --telemetry-url 'ws://localhost:8001/submit 0' ``` -**Note:** The "0" at the end of the URL is a verbosity level, and not part of the URL itself. Verbosity levels range from 0-9, with 0 denoting the lowest verbosity. +**Note:** The "0" at the end of the URL is a verbosity level, and not part of the URL itself. Verbosity levels range from 0-9, with 0 denoting the lowest verbosity. The URL and this verbosity level are parts of a single argument and must therefore be surrounded in quotes (as seen above) in order to be treated as such by your shell. ## Docker diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 69986e8..ae7d6ca 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -15,18 +15,19 @@ FROM docker.io/nginx:stable-alpine LABEL maintainer="Chevdor " LABEL description="Polkadot Telemetry frontend" +# When we run the built docker image, the default command uses this +# env var to tell the UI where to look to get feed info. ENV SUBSTRATE_TELEMETRY_URL= WORKDIR /usr/share/nginx/html -#COPY --from=builder /opt/builder/env.sh /usr/bin/ -#RUN apk add --no-cache bash; chmod +x /usr/bin/env.sh +COPY --from=builder /opt/builder/env.sh /usr/bin/ +RUN apk add --no-cache bash; chmod +x /usr/bin/env.sh -#COPY --from=builder /opt/builder/nginx/nginx.conf /etc/nginx/nginx.conf -#COPY --from=builder /opt/builder/nginx/default /etc/nginx/sites-available/default +COPY --from=builder /opt/builder/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=builder /opt/builder/nginx/default /etc/nginx/sites-available/default COPY --from=builder /opt/builder/build /usr/share/nginx/html EXPOSE 80 -#CMD ["/bin/bash", "-c", "/usr/bin/env.sh && nginx -g \"daemon off;\""] -CMD [ "nginx", "-g" ,"daemon off;"] +CMD ["/bin/bash", "-c", "/usr/bin/env.sh && nginx -g \"daemon off;\""] diff --git a/helm/templates/frontend-deployment.yaml b/helm/templates/frontend-deployment.yaml index 8bb737f..5bb4039 100644 --- a/helm/templates/frontend-deployment.yaml +++ b/helm/templates/frontend-deployment.yaml @@ -59,19 +59,12 @@ spec: mountPath: /etc/nginx/nginx.conf subPath: nginx.conf readOnly: true - - name: env-config - mountPath: /usr/share/nginx/html/env-config.js - subPath: env-config.js - readOnly: true resources: {{- toYaml .Values.resources | nindent 12 }} volumes: - name: nginx configMap: name: frontend-nginx - - name: env-config - configMap: - name: frontend-env-config {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/helm/templates/frontend-env-config.yaml b/helm/templates/frontend-env-config.yaml deleted file mode 100644 index 4d2a563..0000000 --- a/helm/templates/frontend-env-config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: frontend-env-config -data: - env-config.js: | - window.process_env = { - SUBSTRATE_TELEMETRY_URL: "wss://feed.telemetry.parity-stg.parity.io/feed", - SUBSTRATE_TELEMETRY_SAMPLE: "", - } diff --git a/helm/values.yaml b/helm/values.yaml index fcd55ed..28fe64b 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -26,7 +26,10 @@ fullnameOverride: "" envVars: shard: {} core: {} - frontend: {} + frontend: + # The frontend docker container makes this available to the UI, + # so that it knows where to look for feed information: + SUBSTRATE_TELEMETRY_URL: wss://feed.telemetry.parity-stg.parity.io/feed