#!/bin/sh set -eu # Ensure data dir exists and is writable by botuser (volume may be root-owned) mkdir -p /app/data chown botuser:botuser /app/data # Apply Alembic migrations (runs as root, creates DB in /app/data) alembic -c pyproject.toml upgrade head # Ensure new DB file is owned by botuser so the app can write chown -R botuser:botuser /app/data # Run the app as botuser exec gosu botuser "$@"