move migration and server into same thing

This commit is contained in:
2025-06-02 02:32:28 +02:00
parent b3ce3d5067
commit 620b5ee9b1

View File

@@ -1,51 +1,4 @@
# --------------------------------------------------------------------
# 5a) Job: affine-migration (runs once at startup to initialize the DB)
# --------------------------------------------------------------------
apiVersion: batch/v1
kind: Job
metadata:
name: affine-migration
namespace: affine
spec:
backoffLimit: 2
template:
metadata:
labels:
job: affine-migration
spec:
restartPolicy: OnFailure
containers:
- name: affine-migrate
image: ghcr.io/toeverything/affine-graphql:canary-2e58c11
command: ["sh", "-c", "node ./scripts/self-host-predeploy.js"]
env:
- name: REDIS_SERVER_HOST
value: "redis-lb.redis.svc.cluster.local"
- name: REDIS_SERVER_PORT
value: "6379"
- name: DATABASE_URL
value: >-
postgresql://$(DB_USERNAME):$(DB_PASSWORD)@postgres-base-rw.postgres.svc.cluster.local:5432/$(DB_DATABASE)
- name: AFFINE_SERVER_PORT
value: "3010"
envFrom:
- secretRef:
name: affine-db-secret
volumeMounts:
- name: affine-storage
mountPath: /root/.affine/storage
- name: affine-config
mountPath: /root/.affine/config
volumes:
- name: affine-storage
persistentVolumeClaim:
claimName: affine-storage-pvc
- name: affine-config
persistentVolumeClaim:
claimName: affine-config-pvc
---
# --------------------------------------------------------------------
# 5b) Deployment: affine-server (serves HTTP on port 3010)
# --------------------------------------------------------------------
apiVersion: apps/v1
@@ -65,6 +18,28 @@ spec:
labels:
app: affine-server
spec:
initContainers:
- name: affine-migrate
image: ghcr.io/toeverything/affine-graphql:canary-2e58c11
command: ["sh", "-c", "node ./scripts/self-host-predeploy.js"]
env:
- name: REDIS_SERVER_HOST
value: "redis-lb.redis.svc.cluster.local"
- name: REDIS_SERVER_PORT
value: "6379"
- name: DATABASE_URL
value: >
postgresql://$(DB_USERNAME):$(DB_PASSWORD)@postgres-base-rw.postgres.svc.cluster.local:5432/$(DB_DATABASE)
- name: AFFINE_SERVER_PORT
value: "3010"
envFrom:
- secretRef:
name: affine-db-secret
volumeMounts:
- name: affine-storage
mountPath: /root/.affine/storage
- name: affine-config
mountPath: /root/.affine/config
containers:
- name: affine
image: ghcr.io/toeverything/affine-graphql:canary-2e58c11
@@ -93,7 +68,6 @@ spec:
- secretRef:
name: affine-db-secret
readinessProbe:
# If Affine supports an HTTP health endpoint, replace “/health” with the actual path.
httpGet:
path: /health
port: 3010