Preserve production database - only copy if missing/empty
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 4s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 3s

- Add conditional logic to only copy database if target doesn't exist or is 0 bytes
- This preserves production data across pod restarts
- Only copy from preload when database is missing or corrupted
- Keep debug ls output to verify file size
This commit is contained in:
2025-12-29 00:46:58 +01:00
parent 39762037fe
commit b0b44eeed4

View File

@@ -21,7 +21,7 @@ spec:
image: git.baumann.gr/adebaumann/labhelper-data-loader:0.009 image: git.baumann.gr/adebaumann/labhelper-data-loader:0.009
securityContext: securityContext:
runAsUser: 0 runAsUser: 0
command: [ "sh","-c","cp -f preload/preload.sqlite3 /data/db.sqlite3 && cd /app && python manage.py migrate thumbnail --run-syncdb && mkdir -p /data/media/cache /data/media/things && chmod -R 775 /data/media && ls -la /data/db.sqlite3 && exit 0" ] command: [ "sh","-c","if [ ! -f /data/db.sqlite3 ] || [ ! -s /data/db.sqlite3 ]; then cp preload/preload.sqlite3 /data/db.sqlite3 && echo 'Database copied from preload'; else echo 'Existing database preserved'; fi && cd /app && python manage.py migrate thumbnail --run-syncdb && mkdir -p /data/media/cache /data/media/things && chmod -R 775 /data/media && ls -la /data/db.sqlite3 && exit 0" ]
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /data mountPath: /data