mirror of
https://github.com/saltbo/zpan.git
synced 2026-09-01 15:49:00 +08:00
8005defd97
* feat: add libSQL (Turso) platform adapter and Docker opt-in - server/platform/libsql.ts: createLibsqlPlatform() using @libsql/client + drizzle-orm/libsql; accepts plain env record; async migrate at boot; authToken optional for file:// URLs - server/entry-node.ts: select platform at startup — libsql when TURSO_DATABASE_URL is set, otherwise existing SQLite via createNodePlatform() - drizzle.config.ts: switch to turso dialect when TURSO_DATABASE_URL is set - vitest.libsql.config.ts + server/platform/libsql.libsql-test.ts: smoke suite covering connect, migrations, insert/select against users + storages tables - package.json: add @libsql/client dependency; add test:libsql script; externalize @libsql/client in build:node tsup command - vitest.config.ts: exclude *.libsql-test.ts from coverage - docs/deploy/docker.md: document Turso opt-in with copy-pasteable docker-compose snippet - CONTRIBUTING.md: add Turso migrate path paragraph under Database Migrations Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f * refactor: turn bootstrap.ts into a Platform-accepting factory - server/bootstrap.ts: replace singleton module-scope script with exportable createBootstrap(platform) async factory; reads BETTER_AUTH_SECRET/BETTER_AUTH_URL/TRUSTED_ORIGINS from platform.getEnv so every future entry (Lambda, Vercel, Netlify, Azure) can reuse it - server/entry-node.ts: slim down to platform selection + createBootstrap call; no more duplicate auth/app wiring - server/dev.ts: thin vite-dev-server entry that creates NodePlatform and calls createBootstrap; replaces the former default export in bootstrap.ts - vite.config.ts: update node dev server entry to server/dev.ts - server/platform/libsql.ts: fix getEnv to check env record before falling back to process.env, matching the cloudflare.ts pattern Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f * style: apply biome auto-fixes for pre-existing lint issues Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f --------- Co-authored-by: Bob <aibob@mails.agent-kanban.dev>
71 lines
2.1 KiB
Markdown
71 lines
2.1 KiB
Markdown
# Docker Deployment
|
|
|
|
ZPan ships as a single Docker image. By default it uses an embedded SQLite database (`better-sqlite3`). For production multi-replica deployments you can opt into [Turso](https://turso.tech) (libSQL) as a shared remote database.
|
|
|
|
## Default: local SQLite
|
|
|
|
No extra configuration needed. Mount a volume so the database survives container restarts:
|
|
|
|
```yaml
|
|
services:
|
|
zpan:
|
|
image: ghcr.io/saltbo/zpan:latest
|
|
ports:
|
|
- "8222:8222"
|
|
environment:
|
|
PORT: 8222
|
|
BETTER_AUTH_SECRET: <generate with: openssl rand -base64 32>
|
|
BETTER_AUTH_URL: https://your-domain.example
|
|
DATABASE_URL: /data/zpan.db
|
|
volumes:
|
|
- zpan-data:/data
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
zpan-data:
|
|
```
|
|
|
|
Migrations run automatically at startup.
|
|
|
|
## Turso (libSQL) opt-in
|
|
|
|
Set `TURSO_DATABASE_URL` to switch from local SQLite to a Turso (or self-hosted libSQL) database. `TURSO_AUTH_TOKEN` is required for remote URLs; it can be omitted for local `file://` URLs.
|
|
|
|
```yaml
|
|
services:
|
|
zpan:
|
|
image: ghcr.io/saltbo/zpan:latest
|
|
ports:
|
|
- "8222:8222"
|
|
environment:
|
|
PORT: 8222
|
|
BETTER_AUTH_SECRET: <generate with: openssl rand -base64 32>
|
|
BETTER_AUTH_URL: https://your-domain.example
|
|
TURSO_DATABASE_URL: libsql://your-db-name-orgname.turso.io
|
|
TURSO_AUTH_TOKEN: <your-turso-auth-token>
|
|
restart: unless-stopped
|
|
```
|
|
|
|
When `TURSO_DATABASE_URL` is present:
|
|
- `DATABASE_URL` is ignored.
|
|
- Migrations are applied automatically at startup via `drizzle-orm/libsql/migrator`.
|
|
- `TURSO_AUTH_TOKEN` may be omitted only for `file://` URLs (local libSQL files).
|
|
|
|
### Running migrations manually against Turso
|
|
|
|
```sh
|
|
TURSO_DATABASE_URL=libsql://your-db.turso.io \
|
|
TURSO_AUTH_TOKEN=your-token \
|
|
npm run db:migrate
|
|
```
|
|
|
|
`drizzle.config.ts` automatically switches to the `turso` dialect when `TURSO_DATABASE_URL` is set, so `npm run db:generate` and `npm run db:migrate` work against Turso without any extra flags.
|
|
|
|
### Obtaining a Turso auth token
|
|
|
|
```sh
|
|
turso db tokens create your-db-name
|
|
```
|
|
|
|
Or create one in the [Turso dashboard](https://app.turso.tech).
|