fusero-app-boilerplate/chart/templates/backend-migration.job.yaml
liquidrinu 5c3833a9e4
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 6m2s
fix: correct shell script syntax in migration job init container
2025-05-25 13:17:58 +02:00

49 lines
1.4 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: fusero-backend-db-init
spec:
backoffLimit: 0
template:
metadata:
name: fusero-backend-db-init
spec:
imagePullSecrets:
- name: regcred
initContainers:
- name: wait-for-postgres
image: postgres:15
command:
- /bin/sh
- -c
- |
echo "Waiting for PostgreSQL to be ready..."
for i in $(seq 1 30); do
if pg_isready -h postgres-service -p 5432 -U prod_admin; then
echo "PostgreSQL is ready!"
exit 0
fi
echo "Attempt $i: PostgreSQL is not ready yet. Waiting..."
sleep 10
done
echo "PostgreSQL failed to become ready in time"
exit 1
env:
- name: PGPASSWORD
value: "{{ .Values.backend.env.POSTGRES_PASSWORD }}"
containers:
- name: migrate-seed
image: {{ .Values.backend.image }}
command: ["/bin/sh", "-c"]
args:
- |
echo "Running migrations and seeds..." && \
npx mikro-orm migration:up && \
npm run seed
env:
{{- range $key, $val := .Values.backend.env }}
- name: {{ $key }}
value: "{{ $val }}"
{{- end }}
restartPolicy: Never