Immich: Add db-init job for database setup and update kustomization files

This commit is contained in:
2025-05-28 15:15:57 -07:00
parent 11fe563f18
commit 72cd0ecf56
5 changed files with 31 additions and 10 deletions

View File

@@ -1 +1,7 @@
# Immich App # Immich App
## To Do
- We need a full uninstall script.
- We need full backup and restore scripts.
- When recreating the app (uninstall/reinstall), db-init needs to re-run (currently the previous one blocks).

View File

@@ -29,9 +29,24 @@ spec:
# Connect to the immich database and enable required extensions # Connect to the immich database and enable required extensions
PGPASSWORD=${POSTGRES_ADMIN_PASSWORD} psql -h ${DB_HOSTNAME} -U postgres -d ${DB_DATABASE_NAME} <<EOF PGPASSWORD=${POSTGRES_ADMIN_PASSWORD} psql -h ${DB_HOSTNAME} -U postgres -d ${DB_DATABASE_NAME} <<EOF
CREATE EXTENSION IF NOT EXISTS vector; DO \$\$
CREATE EXTENSION IF NOT EXISTS cube; BEGIN
CREATE EXTENSION IF NOT EXISTS earthdistance; -- Create vector extension if it doesn't exist
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'vector') THEN
CREATE EXTENSION vector;
END IF;
-- Create cube extension if it doesn't exist
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'cube') THEN
CREATE EXTENSION cube;
END IF;
-- Create earthdistance extension if it doesn't exist (depends on cube)
IF NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'earthdistance') THEN
CREATE EXTENSION earthdistance;
END IF;
END
\$\$;
EOF EOF
env: env:
- name: POSTGRES_ADMIN_PASSWORD - name: POSTGRES_ADMIN_PASSWORD

View File

@@ -1,4 +0,0 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- db-init-job.yaml

View File

@@ -6,14 +6,14 @@ labels:
pairs: pairs:
app: immich app: immich
managedBy: kustomize managedBy: kustomize
partOf: sovereign-cloud partOf: wild-cloud
resources: resources:
- deployment.yaml - deployment.yaml
- ingress.yaml - ingress.yaml
- namespace.yaml - namespace.yaml
- pvc.yaml - pvc.yaml
- service.yaml - service.yaml
- init/ - db-init-job.yaml
configMapGenerator: configMapGenerator:
- name: config - name: config
envs: envs:

View File

@@ -13,6 +13,8 @@ spec:
selector: selector:
app: immich app: immich
component: server component: server
managedBy: kustomize
partOf: wild-cloud
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@@ -27,3 +29,5 @@ spec:
selector: selector:
app: immich app: immich
component: machine-learning component: machine-learning
managedBy: kustomize
partOf: wild-cloud