Fix database not initializing in Docker (no db file created)
Root cause: DATABASE_URL used a relative path (file:./data/rackmapper.db).
Prisma CLI (migrate deploy) resolves relative SQLite paths from the
prisma/ schema directory -> /app/prisma/data/rackmapper.db, while the
Prisma Client at runtime resolves from CWD -> /app/data/rackmapper.db.
The migration ran against a different path than the bind mount, so no
database file ever appeared in /app/data (the mounted volume).
Fixes:
- Change DATABASE_URL to absolute path: file:/app/data/rackmapper.db
everywhere (docker-compose, .env.example, UNRAID.md)
- Replace inline CMD with docker-entrypoint.sh:
mkdir -p /app/data before migrating (safety net)
npx prisma migrate deploy with set -e so failures are visible
exec node dist/server/index.js
This surfaces migration errors in docker logs instead of silently
exiting, and ensures the data dir always exists before SQLite opens it
- Update .env.example to reflect plain ADMIN_PASSWORD and COOKIE_SECURE
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17
docker-entrypoint.sh
Normal file
17
docker-entrypoint.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "[entrypoint] RackMapper starting..."
|
||||
|
||||
# Ensure the data directory exists and is writable
|
||||
mkdir -p /app/data
|
||||
echo "[entrypoint] Data directory: $(ls -la /app/data)"
|
||||
|
||||
# Run migrations (creates the SQLite file if it doesn't exist)
|
||||
echo "[entrypoint] Running database migrations..."
|
||||
npx prisma migrate deploy
|
||||
echo "[entrypoint] Migrations complete."
|
||||
|
||||
# Start the server
|
||||
echo "[entrypoint] Starting server..."
|
||||
exec node dist/server/index.js
|
||||
Reference in New Issue
Block a user