job-assets-precompile.yaml 3.5 KB

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