From 011d1a3836c200698d37aee6c2693ed2e6dcd540 Mon Sep 17 00:00:00 2001 From: levivannoort Date: Tue, 3 Oct 2023 09:28:05 +0200 Subject: [PATCH] feat: add init-container for prisma migration on start-up --- plugins/deployment-helm-chart/package-lock.json | 4 ++-- plugins/deployment-helm-chart/package.json | 2 +- .../src/static/chart/templates/deployment.yaml | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/deployment-helm-chart/package-lock.json b/plugins/deployment-helm-chart/package-lock.json index 9044955c..f188ae17 100644 --- a/plugins/deployment-helm-chart/package-lock.json +++ b/plugins/deployment-helm-chart/package-lock.json @@ -1,12 +1,12 @@ { "name": "@amplication/plugin-deployment-helm-chart", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@amplication/plugin-deployment-helm-chart", - "version": "1.0.2", + "version": "1.0.3", "license": "Apache-2.0", "devDependencies": { "@amplication/code-gen-types": "^2.0.1", diff --git a/plugins/deployment-helm-chart/package.json b/plugins/deployment-helm-chart/package.json index d972a335..341609eb 100644 --- a/plugins/deployment-helm-chart/package.json +++ b/plugins/deployment-helm-chart/package.json @@ -1,6 +1,6 @@ { "name": "@amplication/plugin-deployment-helm-chart", - "version": "1.0.2", + "version": "1.0.3", "description": "Add helm chart for deployment of the service", "main": "dist/index.js", "scripts": { diff --git a/plugins/deployment-helm-chart/src/static/chart/templates/deployment.yaml b/plugins/deployment-helm-chart/src/static/chart/templates/deployment.yaml index bc309888..099e1e53 100644 --- a/plugins/deployment-helm-chart/src/static/chart/templates/deployment.yaml +++ b/plugins/deployment-helm-chart/src/static/chart/templates/deployment.yaml @@ -30,6 +30,21 @@ spec: serviceAccountName: {{ include "${{ SERVICE_NAME }}.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if or .Values.variables.configmap.DB_URL .Values.variables.secret.DB_URL }} + initContainers: + - name: {{ .Chart.Name }}-prisma-migrate + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + command: ["sh", "-c", "npx prisma migrate deploy; exit 0"] + {{- if .Values.variables.configmap.DB_URL }} + env: + - name: DATABASE_URL + value: {{ required ".Values.variables.configmap.DB_URL is required" .Values.variables.configmap.DB_URL }} + {{- else if .Values.variables.secret.DB_URL }} + env: + - name: DATABASE_URL + value: {{ required ".Values.variables.configmap.DB_URL is required" .Values.variables.configmap.DB_URL }} + {{- end }} + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: