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

Make NGINX serve static content directly #331

Merged
merged 4 commits into from
Sep 30, 2021
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions galaxy/templates/configmap-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +38,11 @@ data:
listen 80;
server_name galaxy;

location {{ template "galaxy.add_trailing_slash" .Values.ingress.path }}static {
alias {{ .Values.nginx.galaxyStaticDir }};
expires 24h;
}

location {{ template "galaxy.add_trailing_slash" .Values.ingress.path }} {
uwsgi_pass {{ template "galaxy.fullname" . }}-uwsgi:4001;
uwsgi_param UWSGI_SCHEME $scheme;
Expand Down
13 changes: 13 additions & 0 deletions galaxy/templates/deployment-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -44,6 +52,9 @@ spec:
- name: nginx-conf
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: static-dir
mountPath: {{ .Values.nginx.galaxyStaticDir }}
subPath: static
- name: galaxy-data
mountPath: {{ .Values.persistence.mountPath }}
- name: galaxy-data
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions galaxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,5 @@ nginx:
pullPolicy: IfNotPresent
conf:
client_max_body_size: 100g
galaxyStaticDir: "/galaxy/server/static"