feat: implement Docker support with entrypoint script and environment configuration for data directory

This commit is contained in:
2025-11-13 03:07:03 +01:00
parent 5afd604e85
commit 23cdc27ffd
6 changed files with 113 additions and 5 deletions

29
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
set -eu
DATA_DIR="${DATA_DIR:-/data}"
SCHEMA_PATH="./prisma/schema.prisma"
# ensure data dir exists and is writable
mkdir -p "$DATA_DIR"
chmod 0775 "$DATA_DIR" || true
# ensure DATABASE_URL is set to the runtime DATA_DIR
: "${DATABASE_URL:=file:${DATA_DIR}/sqlite.db}"
export DATABASE_URL
# create sqlite file if missing
SQLITE_DB_PATH="${DATA_DIR}/sqlite.db"
if [ ! -f "$SQLITE_DB_PATH" ]; then
touch "$SQLITE_DB_PATH"
chmod 0664 "$SQLITE_DB_PATH" || true
fi
# run non-interactive migrations if CLI available
if command -v npx >/dev/null 2>&1 && [ -f "$SCHEMA_PATH" ]; then
echo "Running prisma migrate deploy..."
npx prisma migrate deploy --schema="$SCHEMA_PATH" || echo "prisma migrate deploy failed or no migrations to apply"
fi
# exec main process
exec "$@"