job-assets-precompile.yaml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. spec:
  16. restartPolicy: Never
  17. {{- if (not .Values.mastodon.s3.enabled) }}
  18. # ensure we run on the same node as the other rails components; only
  19. # required when using PVCs that are ReadWriteOnce
  20. {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }}
  21. affinity:
  22. podAffinity:
  23. requiredDuringSchedulingIgnoredDuringExecution:
  24. - labelSelector:
  25. matchExpressions:
  26. - key: component
  27. operator: In
  28. values:
  29. - rails
  30. topologyKey: kubernetes.io/hostname
  31. {{- end }}
  32. volumes:
  33. - name: assets
  34. persistentVolumeClaim:
  35. claimName: {{ template "mastodon.fullname" . }}-assets
  36. - name: system
  37. persistentVolumeClaim:
  38. claimName: {{ template "mastodon.fullname" . }}-system
  39. {{- end }}
  40. containers:
  41. - name: {{ include "mastodon.fullname" . }}-assets-precompile
  42. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  43. imagePullPolicy: {{ .Values.image.pullPolicy }}
  44. command:
  45. - bash
  46. - -c
  47. - |
  48. bundle exec rake assets:precompile && yarn cache clean
  49. envFrom:
  50. - configMapRef:
  51. name: {{ include "mastodon.fullname" . }}-env
  52. - secretRef:
  53. name: {{ template "mastodon.secretName" . }}
  54. env:
  55. - name: "DB_PASS"
  56. valueFrom:
  57. secretKeyRef:
  58. name: {{ template "mastodon.postgresql.secretName" . }}
  59. key: password
  60. - name: "REDIS_PASSWORD"
  61. valueFrom:
  62. secretKeyRef:
  63. name: {{ template "mastodon.redis.secretName" . }}
  64. key: redis-password
  65. - name: "PORT"
  66. value: {{ .Values.mastodon.web.port | quote }}
  67. {{- if (not .Values.mastodon.s3.enabled) }}
  68. volumeMounts:
  69. - name: assets
  70. mountPath: /opt/mastodon/public/assets
  71. - name: system
  72. mountPath: /opt/mastodon/public/system
  73. {{- end }}