diff --git a/gui/.env.development b/gui/.env.development index f636c30c63ecd377840aa33efddca56c19af059e..bcb1e4a108cd434d12c7d4e32d30a523b738b00d 100644 --- a/gui/.env.development +++ b/gui/.env.development @@ -1,5 +1,4 @@ REACT_APP_API_BASE = 'http://localhost:8000/nomad/api' -REACT_APP_OBJECT_BASE = 'http://localhost:9007' REACT_APP_APP_BASE = '/nomad' REACT_APP_APP_STATIC_BASE = '' REACT_APP_DEBUG = 'true' \ No newline at end of file diff --git a/gui/.env.production b/gui/.env.production index 7755d9dcad9e47d2023b15e0c718a9f41f268ae2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/gui/.env.production +++ b/gui/.env.production @@ -1,5 +0,0 @@ -REACT_APP_API_BASE = '/nomad/api' -REACT_APP_OBJECT_BASE = '/nomad/objects' -REACT_APP_APP_BASE = '/nomad' -REACT_APP_APP_STATIC_BASE = '/nomad' -REACT_APP_DEBUG = 'true' \ No newline at end of file diff --git a/gui/public/index.html b/gui/public/index.html index e87935922e0220b893101ebc8597cc48cad0a132..a2e02c183170a80bb29677b433c2c28701813c13 100644 --- a/gui/public/index.html +++ b/gui/public/index.html @@ -29,6 +29,7 @@ <noscript> You need to enable JavaScript to run this app. </noscript> + <script src="%PUBLIC_URL%/env.js"></script> <div id="root"></div> <!-- This HTML file is a template. diff --git a/gui/src/config.js b/gui/src/config.js index a3508695f6fbcb61f331e77a805f88213d037e85..3bc06cc0be201d8fd627682e023eaa301ba519d7 100644 --- a/gui/src/config.js +++ b/gui/src/config.js @@ -5,11 +5,11 @@ import analytics from '@material-ui/core/colors/lightGreen' import secondary from '@material-ui/core/colors/blueGrey' import { createMuiTheme } from '@material-ui/core' -export const apiBase = process.env.REACT_APP_API_BASE -export const objectsBase = process.env.REACT_APP_OBJECT_BASE -export const appBase = process.env.REACT_APP_APP_BASE -export const appStaticBase = process.env.REACT_APP_APP_STATIC_BASE -export const debug = process.env.REACT_APP_DEBUG === 'true' +window.nomad_env = window.nomad_env || {} +export const apiBase = process.env.REACT_APP_API_BASE || window.nomad_env.apiBase +export const appBase = process.env.REACT_APP_APP_BASE || window.nomad_env.appBase +export const appStaticBase = process.env.REACT_APP_APP_STATIC_BASE || window.nomad_env.appStaticBase +export const debug = process.env.REACT_APP_DEBUG ? process.env.REACT_APP_DEBUG === 'true' : window.nomad_env.debug export const genTheme = createMuiTheme({ palette: { diff --git a/ops/helm/nomad/templates/gui-deployment.yml b/ops/helm/nomad/templates/gui-deployment.yml index 2c6cff0ecd80e14a890a9fb1ed8d01016217a883..b0cd44f006cef87fcf9212e6739034875424d154 100644 --- a/ops/helm/nomad/templates/gui-deployment.yml +++ b/ops/helm/nomad/templates/gui-deployment.yml @@ -21,6 +21,19 @@ data: try_files $uri /nomad/index.html; # fall back to index.html to support routing } } + env.js: | + window.nomadEnv = { + {{- if .Values.proxy.external.useReleasePath }} + "apiBase": "{{ .Values.proxy.external.path }}/{{ .Release.Name }}/api", + "appBase": "{{ .Values.proxy.external.path }}/{{ .Release.Name }}", + "appStaticBase": "{{ .Values.proxy.external.path }}/{{ .Release.Name }}", + {{- else }} + "apiBase": "{{ .Values.proxy.external.path }}/api", + "appBase": "{{ .Values.proxy.external.path }}", + "appStaticBase": "{{ .Values.proxy.external.path }}", + {{- end }} + "appDebug": false + }; --- apiVersion: apps/v1 kind: Deployment @@ -57,6 +70,9 @@ spec: name: nginx-conf - mountPath: /var/log/nginx name: log + - mountPath: /app/nomad + readOnly: true + name: nomad-app volumes: - name: nginx-conf configMap: @@ -64,5 +80,11 @@ spec: items: - key: nginx.conf path: default.conf + - name: nomad-app + configMap: + name: {{ include "nomad.fullname" . }}-gui-config + items: + - key: env.js + path: env.js - name: log emptyDir: {}