add directory creation for SQLite database in create_app function; remove init container for SQLite

This commit is contained in:
Michael Trip 2026-01-09 22:20:52 +01:00
parent bdb61fe1b7
commit 7209d3fed0
2 changed files with 9 additions and 9 deletions

View file

@ -26,6 +26,15 @@ def create_app():
# Initialize database tables
with app.app_context():
# Create data directory if it doesn't exist
import os
db_path = app.config.get('SQLALCHEMY_DATABASE_URI', '')
if db_path.startswith('sqlite:///'):
db_file_path = db_path.replace('sqlite:///', '')
db_dir = os.path.dirname(db_file_path)
if db_dir and not os.path.exists(db_dir):
os.makedirs(db_dir, exist_ok=True)
db.create_all()
return app

View file

@ -35,15 +35,6 @@ spec:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
initContainers:
- name: init-sqlite
image: busybox:1.35
command: ['sh', '-c', 'mkdir -p /app/data && chown -R 1001:1001 /app/data']
volumeMounts:
- name: sqlite-data
mountPath: /app/data
securityContext:
runAsUser: 0 # Run as root for chown
containers:
- name: snauw-counter
image: ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG:-latest}