aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-06-07 20:28:47 +0100
committerGravatar Joe Banks <[email protected]>2024-06-07 20:28:47 +0100
commite70bc7846a319785e35fe7db3dfd98d38ddbadaa (patch)
treefebafba8e0fd54ff922005930bd9c9dad5f09fd9
parentUpdate Grafana repository to use explicit keyring (diff)
Update site to run migrations in an init container
In accordance with updates from python-discord/site#1338 this changes the way migrations are run. Previously, migrations would be run all from within the manage.py execution process with the command being manually spawned using Django internals. After python-discord/site#1338 merges the Dockerfile will directly invoke gunicorn and bypass manage.py to simplify the process and avoid problems with shared database contexts. Hence, we need to manually run migrations using an init container. With testing there is no additional delay in doing this as spinning up an init container is cheap and we don't cut over any traffic until the site passes a healthcheck anyway.
-rw-r--r--kubernetes/namespaces/web/site/deployment.yaml13
1 files changed, 13 insertions, 0 deletions
diff --git a/kubernetes/namespaces/web/site/deployment.yaml b/kubernetes/namespaces/web/site/deployment.yaml
index bdb4073..abaf28d 100644
--- a/kubernetes/namespaces/web/site/deployment.yaml
+++ b/kubernetes/namespaces/web/site/deployment.yaml
@@ -13,6 +13,19 @@ spec:
labels:
app: site
spec:
+ initContainers:
+ - name: migrations
+ image: ghcr.io/python-discord/site:latest
+ imagePullPolicy: Always
+ command:
+ - sh
+ - -c
+ - "poetry run python manage.py migrate"
+ envFrom:
+ - secretRef:
+ name: site-env
+ securityContext:
+ readOnlyRootFilesystem: true
containers:
- name: site
image: ghcr.io/python-discord/site:latest