feat: implement Docker support with entrypoint script and environment configuration for data directory
This commit is contained in:
29
docker/entrypoint.sh
Normal file
29
docker/entrypoint.sh
Normal 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 "$@"
|
||||
Reference in New Issue
Block a user