Skip to content

Commit

Permalink
Run migrations in job instead of API pod
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPickering committed Aug 19, 2023
1 parent a1e1bf3 commit 9cde50a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 0 additions & 1 deletion api/scripts/cmd_prd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

set -ex

./m.sh migrate
gunicorn beta_spray.wsgi -b :8000
3 changes: 0 additions & 3 deletions api/src/beta_spray/settings/settings_prd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@
# By not starting this URL with /api/, we avoid collisions between URL matches
# in nginx
STATIC_URL = "/api-static/"

if not GS_BUCKET_NAME: # noqa F405
raise ValueError("Media GCS bucket `GS_BUCKET_NAME` not set.")
37 changes: 37 additions & 0 deletions deploy/helm/templates/migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: Job
metadata:
# We have to version this because existing jobs can't be overwritten
name: "migrations-{{ .Release.Revision }}"
namespace: "{{ .Release.Namespace }}"
spec:
template:
spec:
containers:
- name: migrations
image: "ghcr.io/lucaspickering/beta-spray-api:{{ .Values.versionSha }}"
command: ["./m.sh", "migrate"]
resources:
requests:
cpu: 50m
memory: 150Mi
env:
- name: BETA_SPRAY_DB_HOST
value: db
- name: BETA_SPRAY_DB_NAME
valueFrom:
secretKeyRef:
name: database-creds
key: database
- name: BETA_SPRAY_DB_USER
valueFrom:
secretKeyRef:
name: database-creds
key: username
- name: BETA_SPRAY_DB_PASSWORD
valueFrom:
secretKeyRef:
name: database-creds
key: password
restartPolicy: Never
backoffLimit: 2

0 comments on commit 9cde50a

Please sign in to comment.