job-assets-precompile.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. apiVersion: batch/v1
  2. kind: Job
  3. metadata:
  4. name: {{ include "mastodon.fullname" . }}-assets-precompile
  5. labels:
  6. {{- include "mastodon.labels" . | nindent 4 }}
  7. annotations:
  8. "helm.sh/hook": post-install
  9. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  10. "helm.sh/hook-weight": "-2"
  11. spec:
  12. template:
  13. metadata:
  14. name: {{ include "mastodon.fullname" . }}-assets-precompile
  15. {{- with .Values.jobAnnotations }}
  16. annotations:
  17. {{- toYaml . | nindent 8 }}
  18. {{- end }}
  19. spec:
  20. restartPolicy: Never
  21. {{- if (not .Values.mastodon.s3.enabled) }}
  22. # ensure we run on the same node as the other rails components; only
  23. # required when using PVCs that are ReadWriteOnce
  24. {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }}
  25. affinity:
  26. podAffinity:
  27. requiredDuringSchedulingIgnoredDuringExecution:
  28. - labelSelector:
  29. matchExpressions:
  30. - key: app.kubernetes.io/part-of
  31. operator: In
  32. values:
  33. - rails
  34. topologyKey: kubernetes.io/hostname
  35. {{- end }}
  36. volumes:
  37. - name: assets
  38. persistentVolumeClaim:
  39. claimName: {{ template "mastodon.fullname" . }}-assets
  40. - name: system
  41. persistentVolumeClaim:
  42. claimName: {{ template "mastodon.fullname" . }}-system
  43. {{- end }}
  44. containers:
  45. - name: {{ include "mastodon.fullname" . }}-assets-precompile
  46. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  47. imagePullPolicy: {{ .Values.image.pullPolicy }}
  48. command:
  49. - bash
  50. - -c
  51. - |
  52. bundle exec rake assets:precompile && yarn cache clean
  53. envFrom:
  54. - configMapRef:
  55. name: {{ include "mastodon.fullname" . }}-env
  56. - secretRef:
  57. name: {{ template "mastodon.secretName" . }}
  58. env:
  59. - name: "DB_PASS"
  60. valueFrom:
  61. secretKeyRef:
  62. name: {{ template "mastodon.postgresql.secretName" . }}
  63. key: password
  64. - name: "REDIS_PASSWORD"
  65. valueFrom:
  66. secretKeyRef:
  67. name: {{ template "mastodon.redis.secretName" . }}
  68. key: redis-password
  69. - name: "PORT"
  70. value: {{ .Values.mastodon.web.port | quote }}
  71. {{- if (not .Values.mastodon.s3.enabled) }}
  72. volumeMounts:
  73. - name: assets
  74. mountPath: /opt/mastodon/public/assets
  75. - name: system
  76. mountPath: /opt/mastodon/public/system
  77. {{- end }}