job-assets-precompile.yaml 2.5 KB

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