From f0491113bd65c8cdefecd64cd8588c24d65b202d Mon Sep 17 00:00:00 2001 From: almahmoud Date: Thu, 30 Sep 2021 16:51:12 -0400 Subject: [PATCH 1/4] Add init container to copy static contents --- galaxy/templates/deployment-nginx.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/galaxy/templates/deployment-nginx.yaml b/galaxy/templates/deployment-nginx.yaml index c8e26411..bb931b34 100644 --- a/galaxy/templates/deployment-nginx.yaml +++ b/galaxy/templates/deployment-nginx.yaml @@ -32,6 +32,14 @@ spec: {{- if .Values.webHandlers.podSpecExtra -}} {{- tpl (toYaml .Values.webHandlers.podSpecExtra) . | nindent 6 }} {{- end }} + initContainers: + - name: {{ .Chart.Name }}-init-static + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.nginx.image.pullPolicy }} + volumeMounts: + - name: static-dir + mountPath: /tmp/galaxy + command: ['/bin/sh', '-c', 'cp -r /galaxy/server/static /tmp/galaxy/static;'] containers: - name: {{ .Chart.Name }}-nginx image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}" @@ -44,6 +52,9 @@ spec: - name: nginx-conf mountPath: /etc/nginx/nginx.conf subPath: nginx.conf + - name: static-dir + mountPath: /galaxy/server/static + subPath: static - name: galaxy-data mountPath: {{ .Values.persistence.mountPath }} - name: galaxy-data @@ -73,6 +84,8 @@ spec: - name: nginx-conf configMap: name: {{ template "galaxy.fullname" $ }}-nginx-conf + - name: static-dir + emptyDir: {} - name: galaxy-data {{- if .Values.persistence.enabled }} persistentVolumeClaim: From cabf8146596164a52a6f319138d306377271caa4 Mon Sep 17 00:00:00 2001 From: almahmoud Date: Thu, 30 Sep 2021 16:54:09 -0400 Subject: [PATCH 2/4] Add config to serve static directly --- galaxy/templates/configmap-nginx.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/galaxy/templates/configmap-nginx.yaml b/galaxy/templates/configmap-nginx.yaml index 908aee92..5b2d7371 100644 --- a/galaxy/templates/configmap-nginx.yaml +++ b/galaxy/templates/configmap-nginx.yaml @@ -37,6 +37,11 @@ data: listen 80; server_name galaxy; + location {{ template "galaxy.add_trailing_slash" .Values.ingress.path }}static { + alias /galaxy/server/static; + expires 24h; + } + location {{ template "galaxy.add_trailing_slash" .Values.ingress.path }} { uwsgi_pass {{ template "galaxy.fullname" . }}-uwsgi:4001; uwsgi_param UWSGI_SCHEME $scheme; From 1f960baf0c58a3a3d24219350943c55dd107826d Mon Sep 17 00:00:00 2001 From: almahmoud Date: Thu, 30 Sep 2021 16:58:01 -0400 Subject: [PATCH 3/4] Parametrize location within NGINX pod --- README.md | 2 ++ galaxy/templates/configmap-nginx.yaml | 2 +- galaxy/templates/deployment-nginx.yaml | 2 +- galaxy/values.yaml | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa42ea20..c8248391 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,8 @@ current default values can be found in `values.yaml` file. | `nginx.image.tag` | The Nginx version to pull. | | `nginx.image.repository` | Where to obtain the Nginx container. | | `nginx.image.pullPolicy` | When Kubernetes will [pull](https://kubernetes.io/docs/concepts/containers/images/#updating-images) the Nginx image from the repository. | +| `nginx.galaxyStaticDir` | Location at which to copy Galaxy static content in the NGINX pod init container, for direct serving. Defaults to `/galaxy/server/static` | + # Handlers diff --git a/galaxy/templates/configmap-nginx.yaml b/galaxy/templates/configmap-nginx.yaml index 5b2d7371..10ad3eae 100644 --- a/galaxy/templates/configmap-nginx.yaml +++ b/galaxy/templates/configmap-nginx.yaml @@ -38,7 +38,7 @@ data: server_name galaxy; location {{ template "galaxy.add_trailing_slash" .Values.ingress.path }}static { - alias /galaxy/server/static; + alias {{ .Values.nginx.galaxyStaticDir }}; expires 24h; } diff --git a/galaxy/templates/deployment-nginx.yaml b/galaxy/templates/deployment-nginx.yaml index bb931b34..68c11480 100644 --- a/galaxy/templates/deployment-nginx.yaml +++ b/galaxy/templates/deployment-nginx.yaml @@ -53,7 +53,7 @@ spec: mountPath: /etc/nginx/nginx.conf subPath: nginx.conf - name: static-dir - mountPath: /galaxy/server/static + mountPath: {{ .Values.nginx.galaxyStaticDir }} subPath: static - name: galaxy-data mountPath: {{ .Values.persistence.mountPath }} diff --git a/galaxy/values.yaml b/galaxy/values.yaml index fb530f31..7e4b6bbe 100644 --- a/galaxy/values.yaml +++ b/galaxy/values.yaml @@ -638,4 +638,5 @@ nginx: pullPolicy: IfNotPresent conf: client_max_body_size: 100g + galaxyStaticDir: "/galaxy/server/static" From bae51f7b1fe3a2ab21cd945cc55b1adb22c5f1bc Mon Sep 17 00:00:00 2001 From: almahmoud Date: Thu, 30 Sep 2021 17:14:51 -0400 Subject: [PATCH 4/4] Add mime.types explicitly in nginx conf --- galaxy/templates/configmap-nginx.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/galaxy/templates/configmap-nginx.yaml b/galaxy/templates/configmap-nginx.yaml index 10ad3eae..233b35b3 100644 --- a/galaxy/templates/configmap-nginx.yaml +++ b/galaxy/templates/configmap-nginx.yaml @@ -14,6 +14,7 @@ data: http { default_type application/octet-stream; + include /etc/nginx/mime.types; sendfile on; keepalive_timeout 65; index index.html index.php index.htm;