Files
omnex/deploy/chart-vitrine/backend/templates/migration-job.yaml
T
Xor290 8d857faa45
ci-api / test (push) Successful in 23m32s
ci-web / test (push) Successful in 14m7s
chore: build
2026-09-20 18:52:09 +02:00

59 lines
2.1 KiB
YAML

{{- if .Values.migrationJob.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "backend.fullname" . }}-migrate-{{ .Release.Revision }}
labels:
{{- include "backend.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
backoffLimit: {{ .Values.migrationJob.backoffLimit }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "backend.name" . }}-migrate
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: migrate
spec:
restartPolicy: Never
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
# Migrations are baked into the backend image (see backend/Dockerfile)
# so they always match the version being deployed; this initContainer
# just hands them to the golang-migrate image below via a shared
# emptyDir, since that image has the `migrate` binary but not our SQL.
initContainers:
- name: copy-migrations
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
command: ["sh", "-c", "cp -r /app/migrations/. /migrations/"]
volumeMounts:
- name: migrations
mountPath: /migrations
containers:
- name: migrate
image: "{{ .Values.migrationJob.image.repository }}:{{ .Values.migrationJob.image.tag }}"
imagePullPolicy: {{ .Values.migrationJob.image.pullPolicy }}
args:
- "-path=/migrations"
- "-database=$(DATABASE_URL)"
- "up"
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ include "backend.secretName" . }}
key: DATABASE_URL
volumeMounts:
- name: migrations
mountPath: /migrations
readOnly: true
volumes:
- name: migrations
emptyDir: {}
{{- end }}