From c9f8a93c7f3bbf0149920aba535da219d628c631 Mon Sep 17 00:00:00 2001 From: Markus Scheidgen <markus.scheidgen@gmail.com> Date: Mon, 17 Dec 2018 15:23:11 +0100 Subject: [PATCH] Use branchnames for kubnetes paths. --- .gitlab-ci.yml | 2 +- gui/Dockerfile | 10 ++++++++-- gui/src/config.js | 10 +++++----- ops/helm/nomad/templates/api-deployment.yaml | 8 -------- ops/helm/nomad/templates/proxy-deployment.yml | 16 ---------------- ops/helm/nomad/templates/worker-deployment.yaml | 4 ---- ops/helm/nomad/values.yaml | 3 --- requirements.txt | 1 + 8 files changed, 15 insertions(+), 39 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8acf1d757c..ed070e970d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ buildgui: - ./gitinfo.sh - ls -la src/gitinfo.json - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.mpcdf.mpg.de - - docker build -t $FRONTEND_TEST_IMAGE . + - docker build -t $FRONTEND_TEST_IMAGE --build-arg public_url=http://example.com/nomad/$CI_COMMIT_REF_NAME . - docker push $FRONTEND_TEST_IMAGE except: - /^dev-.*$/ diff --git a/gui/Dockerfile b/gui/Dockerfile index 85bbebe778..2ac26fd119 100644 --- a/gui/Dockerfile +++ b/gui/Dockerfile @@ -28,13 +28,19 @@ COPY yarn.lock /nomad/app/yarn.lock RUN yarn COPY . /nomad/app -RUN yarn build +ARG public_url=http://example.com/nomad +ENV PUBLIC_URL $public_url +RUN yarn run build # production environment FROM nginx:1.13.9-alpine COPY --from=build /nomad/app/build /app/nomad COPY ./gui.conf /etc/nginx/conf.d/default.conf -CMD ["nginx", "-g", "daemon off;"] + +WORKDIR /app/nomad +CMD nginx -g "daemon off;" VOLUME /etc/nginx/conf.d VOLUME /nomad/app/config + +EXPOSE 8080/tcp diff --git a/gui/src/config.js b/gui/src/config.js index 3bc06cc0be..5a95d36474 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' -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 +window.nomadEnv = window.nomadEnv || {} +export const apiBase = process.env.REACT_APP_API_BASE || window.nomadEnv.apiBase +export const appBase = process.env.REACT_APP_APP_BASE || window.nomadEnv.appBase +export const appStaticBase = process.env.REACT_APP_APP_STATIC_BASE || window.nomadEnv.appStaticBase +export const debug = process.env.REACT_APP_DEBUG ? process.env.REACT_APP_DEBUG === 'true' : window.nomadEnv.debug export const genTheme = createMuiTheme({ palette: { diff --git a/ops/helm/nomad/templates/api-deployment.yaml b/ops/helm/nomad/templates/api-deployment.yaml index 065062e5c4..4a521b5a49 100644 --- a/ops/helm/nomad/templates/api-deployment.yaml +++ b/ops/helm/nomad/templates/api-deployment.yaml @@ -43,11 +43,7 @@ spec: - name: NOMAD_API_PORT value: "{{ .Values.proxy.external.port }}" - name: NOMAD_API_BASE_PATH - {{- if .Values.proxy.external.useReleasePath }} - value: "{{ .Values.proxy.external.path }}/{{ .Release.Name }}/api" - {{- else }} value: "{{ .Values.proxy.external.path }}/api" - {{- end }} - name: NOMAD_API_SECRET value: "{{ .Values.api.secret }}" - name: NOMAD_RABBITMQ_HOST @@ -76,9 +72,5 @@ spec: volumes: - name: files-volume hostPath: - {{- if .Values.volumes.useReleasePath }} - path: {{ .Values.volumes.files }}/{{ .Release.Name }} - {{- else }} path: {{ .Values.volumes.files }} - {{- end }} type: Directory diff --git a/ops/helm/nomad/templates/proxy-deployment.yml b/ops/helm/nomad/templates/proxy-deployment.yml index b42af7315d..25dec0788b 100644 --- a/ops/helm/nomad/templates/proxy-deployment.yml +++ b/ops/helm/nomad/templates/proxy-deployment.yml @@ -12,37 +12,21 @@ data: server { listen 80; server_name www.example.com; - {{- if .Values.proxy.external.useReleasePath }} - location {{ .Values.proxy.external.path }}/{{ .Release.Name }} { - {{- else }} location {{ .Values.proxy.external.path }} { - {{- end }} proxy_pass http://{{ include "nomad.fullname" . }}-gui:{{ .Values.gui.port }}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } - {{- if .Values.proxy.external.useReleasePath }} - location {{ .Values.proxy.external.path }}/{{ .Release.Name }}/api { - {{- else }} location {{ .Values.proxy.external.path }}/api { - {{- end }} client_max_body_size 20g; proxy_set_header Host $host; proxy_pass_request_headers on; proxy_pass http://{{ include "nomad.fullname" . }}-api:{{ .Values.api.port }}; } - {{- if .Values.proxy.external.useReleasePath }} - location {{ .Values.proxy.external.path }}/{{ .Release.Name }}/kibana { - {{- else }} location {{ .Values.proxy.external.path }}/kibana { - {{- end }} - {{- if .Values.proxy.external.useReleasePath }} - rewrite ^{{ .Values.proxy.external.path}}/{{ .Release.Name }}/kibana/(.*)$ /$1 break; - {{- else }} rewrite ^{{ .Values.proxy.external.path}}/kibana/(.*)$ /$1 break; - {{- end }} proxy_pass http://{{ .Values.kibana.host }}:{{ .Values.kibana.port }}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/ops/helm/nomad/templates/worker-deployment.yaml b/ops/helm/nomad/templates/worker-deployment.yaml index f24fcbaa5e..1c4ea159bc 100644 --- a/ops/helm/nomad/templates/worker-deployment.yaml +++ b/ops/helm/nomad/templates/worker-deployment.yaml @@ -64,9 +64,5 @@ spec: volumes: - name: files-volume hostPath: - {{- if .Values.volumes.useReleasePath }} - path: {{ .Values.volumes.files }}/{{ .Release.Name }} - {{- else }} path: {{ .Values.volumes.files }} - {{- end }} type: Directory diff --git a/ops/helm/nomad/values.yaml b/ops/helm/nomad/values.yaml index be72c7acd8..ed5b6dd19e 100644 --- a/ops/helm/nomad/values.yaml +++ b/ops/helm/nomad/values.yaml @@ -55,7 +55,6 @@ proxy: host: "localhost" port: 30001 ## Add a path segment with the release name to path, e.g. /nomad/liquid-thunder/... - useReleasePath: true path: "/nomad" ## configuration of the chart dependency for rabbitmq @@ -90,6 +89,4 @@ kibana: ## Everything concerning the data that is used by the service volumes: - ## Add a path segment with the release name to path, e.g. .../fs/liquid-thunder/... - useReleasePath: true files: /scratch/nomad-fair/fs diff --git a/requirements.txt b/requirements.txt index 7c0d4c40e2..00288d570d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ python-logstash gitpython gunicorn structlog +recommonmark m2r requests click -- GitLab