Add Docker packaging and migrate from better-sqlite3 to libsql

Docker self-hosting support:
- Dockerfile (multi-stage Alpine build with tini init)
- docker-compose.yml with named volume for SQLite persistence
- /api/health endpoint for container health checks
- Auto-migration on startup via drizzle-orm/libsql/migrator
- Graceful shutdown (SIGTERM stops scheduler, closes DB)
- Next.js standalone output mode for minimal image size

Database driver migration (better-sqlite3 → @libsql/client):
- Eliminates native C++ compilation, enabling Alpine Docker images
- All DB queries converted from sync to async across services and routes
- DATABASE_URL now uses libsql file: prefix format
- drizzle.config.ts dialect changed to turso for libsql support
- Initial migration files generated in drizzle/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 13:14:57 -05:00
co-authored by Claude Opus 4.6
parent 8f99a20a9c
commit 96213c3086
33 changed files with 3837 additions and 593 deletions
+24
View File
@@ -0,0 +1,24 @@
services:
couch-potato:
build: .
image: couch-potato
container_name: couch-potato
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- couch-potato-data:/data
environment:
- DATABASE_URL=file:/data/sqlite.db
- TMDB_API_KEY=${TMDB_API_KEY}
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
- BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
interval: 30s
timeout: 10s
start_period: 30s
retries: 3
volumes:
couch-potato-data: