Package a self-contained macOS app and harden serving

- Add macos/build.mjs: stages a universal .app outside the checkout, bundles
  and checksums Node, installs production deps per architecture, compiles the
  launcher shim, signs ad-hoc or with a Developer ID, and writes a zip and dmg
  with an optional notarization path.
- Serve precompressed brotli/gzip assets and split admin panels and the public
  pages out of the main bundle.
- Support HTTP range requests, and fix upload and quota accounting, gallery
  download counts and unreadable-file handling.
- Add server HTTP integration tests, a Gitea CI workflow, a catalog backup
  script and a crash screen for the UI.
This commit is contained in:
2026-11-29 06:23:58 +00:00
parent d42727618e
commit b34d34dacb
24 changed files with 2598 additions and 93 deletions
+37 -3
View File
@@ -277,7 +277,7 @@ directly and have no legacy alias.
```bash
npm ci
npm run build # type-checks and bundles dist/
npm run build # type-checks, bundles dist/ and writes .br/.gz copies
npm start # serves dist/ and /api from one Node process
```
@@ -360,6 +360,25 @@ Two independent things to back up:
`GET /api/admin/catalog`, and restore it with `POST /api/admin/catalog`. This does
not include image bytes; keep a file-level backup for those.
`npm run backup` automates item 1 without stopping the server: it writes a consistent
`VACUUM INTO` snapshot of the live catalog (WAL included) to `$LUMINARY_DATA/backups`,
re-opens it to run `PRAGMA integrity_check`, records counts in a manifest and prunes to
the last 14 snapshots. `--keep`, `--dir` and `LUMINARY_BACKUP_DIR` change that; originals
are opt-in because they dwarf the catalog:
```bash
npm run backup # catalog only
npm run backup -- --with-originals --keep 30
# nightly at 02:30, keeping the copy off the data volume
30 2 * * * cd /srv/luminary && /usr/bin/npm run backup -- --with-originals --dir /mnt/backups >> /var/log/luminary-backup.log 2>&1
```
To restore, stop the server, copy `catalog-*.db` back as `lumenroom.db` (delete the old
`-wal`/`-shm` files first) and copy `originals-*/` back into the storage root. Previews,
thumbnails, proofs and denoise renders are regenerable; only `originals/` and
`secret.key` must survive.
---
## Docker
@@ -971,11 +990,21 @@ positions. Camera-lens defaults require both a normalised camera and lens name t
| `npm run server:dev` | Server with `node --watch` |
| `npm run dev` | Vite HMR on 5173 |
| `npm run typecheck` | `tsc --noEmit` |
| `npm test` | Vitest, one pass then exit |
| `npm test` | Vitest, one pass then exit: pure logic plus the server HTTP suite |
| `npm run backup` | Snapshot the catalog (originals optional) without stopping the server |
| `npm run precompress` | Write the `.br`/`.gz` asset copies by hand; `npm run build` does this |
| `npm run check:render` | Headless Chrome check that the 16-bit sidecar and JPEG proxy upload in the same row order |
| `npm run predeploy` | Typecheck, unit suite, render check, then build — run this before pushing a deploy; the build is skipped when only test files changed since the last build |
| `npm run deploy` | Predeploy gate, then rsync, remote build, restart and bundle-hash check (see [Production deployment](#production-deployment)) |
### Continuous integration
`.gitea/workflows/ci.yml` runs on every push and pull request: `npm ci`,
`npm run typecheck`, `npm test` and `npm run build` inside a `node:24-bookworm`
container, then `node --check` on every `server/*.mjs`. It only needs Docker on the
runner, so the same gate works on the LAN Gitea instance. Release binaries are still
built and attached by hand; the workflow is what keeps `main` buildable.
Conventions worth knowing before changing code:
- The server is plain ESM (`.mjs`) with no build step. Keep it framework-free and avoid
@@ -1007,8 +1036,13 @@ Conventions worth knowing before changing code:
| `src/lib/dcp.test.ts` | DCP tag parsing and the camera matrix recipe against LibRaw's own values |
| `src/lib/softProof.test.ts` | ICC parsing (including counted lut16 tables), the printer round trip, gamut threshold, rendering-intent selection and CMYK profiles |
| `src/lib/dcpLibrary.test.ts` | Per-camera DCP library: validation, replacement, forgetting and camera matching |
| `server/http.test.mjs` | Real server on a throwaway data directory: signup/invite rules, cross-owner isolation, upload quota accounting, byte ranges, unreadable files not killing the process, gallery download cap |
There are no server integration tests; the API is exercised through the UI.
`server/http.test.mjs` spawns `server/index.mjs` on a random loopback port with a
temporary `LUMINARY_DATA`, drives it with `fetch` and deletes the directory afterwards,
so it needs no fixtures and never touches a real catalog. Its permission test (an
unreadable original must answer 404 instead of crashing the process) is skipped when the
suite runs as root, because root ignores file modes.
`npm run check:render` covers the one thing the unit suite cannot: what a shader does to
real GPU pixels. It encodes a 16-bit sidecar with the server's own encoder, serves it