Files
luminary/macos/README.md
T
bhursey 7eac7e7ecf Release 0.5.3.1
Ships the offline-start fix for the Windows launcher and the before/after split.
2026-12-01 12:14:31 +00:00

8.6 KiB
Raw Blame History

macOS app (optional)

An additive, self-contained way to produce a double-clickable macOS app of Luminary. The server and Docker workflow stay the source of truth: this folder only packages the existing dist/ + server/ output, and the build writes its artifacts outside the checkout.

Isolation guarantees

  1. The packaging tree is additive. There is no package.json script for this, and no change to Dockerfile, docker-compose.yml or scripts/deploy.mjs. Invoke it directly: node macos/build.mjs. The app uses the same desktop mode the Windows launcher uses (LUMINARY_LOCAL=1), which is off unless a launcher sets it.
  2. Artifacts live outside the repo (default: ~/Library/Caches/luminary-macos). The script refuses an --out inside the checkout, because scripts/deploy.mjs rsyncs the worktree to production and docker build would pull the bundle into its context.
  3. The worktree must be clean outside macos/ before and after a build (the untracked logo.png is tolerated). --allow-dirty overrides it.
  4. Nothing in the app changes at run time. The bundle is the unchanged server/ + dist/ + production node_modules, started with PORT, HOST, NODE_ENV and LUMINARY_DATA — all variables the server already reads.

It must run on macOS: the build needs clang, codesign, ditto, hdiutil, sips and iconutil. The Windows bundle is the one that cross-builds from Linux.

Quick start

On a fresh checkout run npm ci once: the UI build uses vite and tsc from the dev dependencies, and the script copies the production dependencies into the app itself.

node macos/build.mjs                        # host arch, Node 24, ad-hoc signature, zip + dmg
node macos/build.mjs --arch universal       # arm64 + x86_64, both sharp slices
node macos/build.mjs --node v22.23.5        # minimum macOS 11.0 instead of 13.5
node macos/build.mjs --skip-build --sign none

Outputs:

~/Library/Caches/luminary-macos/
  stage/Luminary.app
  Luminary-0.5.3.1-mac-arm64.zip
  Luminary-0.5.3.1-mac-arm64.dmg
  cache/                                   # downloaded node tarballs, icon work

--publish copies the zip and dmg into macos/releases/ with a SHA256SUMS.txt, for transfer to a Mac. .gitignore keeps those archives out of git.

Bundle layout

Luminary.app/Contents/
  Info.plist, PkgInfo
  MacOS/Luminary              native shim (main.c) -> execs the launcher
  Resources/
    launcher.sh               start/stop/status/verify (bash)
    Luminary.icns
    version.txt, README-macos.txt
    runtime/node              official Node for the built architecture
    app/
      server/                 unchanged, minus data/ and *.test.*
      dist/                   unchanged, including .br/.gz variants
      node_modules/           production deps only (sharp for each slice)
      package.json, LICENSE, THIRD_PARTY_NOTICES.md, licenses/

The main executable is a Mach-O shim, not a shell script. Apple treats scripts in Contents/MacOS as resources, and the notary service rejects a bundle whose main executable is not signed native code; the shim is a few lines of C that execs bash launcher.sh, so the launcher stays editable without a rebuild and the bundle can still be signed and notarized.

Node and the minimum macOS version

Node Bundled runtime minimum LSMinimumSystemVersion
v22.18+ macOS 11.0 11.0
v24+ macOS 13.5 13.5

Node 24's official macOS binaries are built against 13.5, so they cannot start on Big Sur or Monterey; a macOS 11 build must bundle Node 22. Both lines run this server: node:sqlite is unflagged from 22.13, type stripping (used by server/denoise-worker.mjs importing a .ts pipeline) from 22.18, and the HTTP integration suite passes under 22.23.5.

--node-bin uses a local binary instead of downloading one; the build warns if otool -L shows libraries outside /usr/lib and /System (a Homebrew node would drag Homebrew's ICU along and fail on a stock Mac).

Signing and notarization

Three modes:

--sign What it does Users see
adhoc (default) codesign --sign - on every Mach-O, then the bundle “Apple could not verify …”, one-time Open Anyway
none no signature the same, and arm64 Macs may refuse to launch it
developer-id signs each nested Mach-O with the Developer ID, hardened runtime and JIT entitlements on executables, then the bundle no warning

Notarization needs a paid Apple Developer Program membership:

xcrun notarytool store-credentials luminary \
  --apple-id you@example.com --team-id TEAMID --password APP_SPECIFIC_PASSWORD

node macos/build.mjs --arch universal \
  --sign developer-id --identity "Developer ID Application: Brian Hursey (TEAMID)" \
  --notarize luminary --publish

The build submits the zip, staples the .app, rebuilds the zip, then creates the dmg and submits and staples that too. entitlements.plist contains allow-jit, allow-unsigned-executable-memory and disable-library-validation — Node needs the first two under the hardened runtime, and sharp loads libvips as a dylib, which library validation would otherwise reject.

Without the certificate everything still works; the first-launch instructions in README-macos.txt cover the Gatekeeper step. macOS 15 and 26 removed the Control-click → Open bypass, so that text names the System Settings path.

Launcher behaviour

Same rules as the Windows launcher (windows/launcher/DESIGN.md):

  • No mutex. runtime.json in the data folder records pid/port, and /api/health is the liveness test: a healthy recorded port is reused, a stale one is replaced.
  • Ports 8787–8887, loopback only. The chosen port is passed as PORT.
  • Data defaults to ~/Library/Application Support/Luminary/data; an existing LUMINARY_DATA wins. Logs go to <data>/logs/.
  • Window: Chrome or Edge in --app mode with its own profile in the data folder; --browser or LUMINARY_WINDOW=browser opens a normal tab; neither installed falls back to the default browser.
  • Server lifetime: detached, so closing the browser does not stop it and reopening the app reuses it. --stop (and Stop Luminary.command next to the app in the dmg) terminates it; --status prints pid, port, health and paths; --verify checks the three files a complete bundle needs.

Test checklist (on the Tahoe machine)

  1. node macos/build.mjs --arch universal --dmg → zip and dmg exist; summary prints arch, Node version, target and hashes.
  2. codesign --verify --deep --strict --verbose=2 stage/Luminary.app → valid.
  3. Copy the app out of the dmg, open it → browser/app window opens on the editor, no sign-in screen (desktop mode).
  4. Launch again while it runs → same port is reused, no second node process; pgrep -fl 'Resources/runtime/node' shows one.
  5. --stop → process gone, runtime.json removed; --stop again says "not running".
  6. Occupy 8787 with another listener → the app starts on 8788 and opens that URL.
  7. Import a raw, apply a film look, export → proves libraw WASM, sharp (dylibs load under the signature) and the export path.
  8. Denoise a photo → proves the .ts worker under the bundled Node.
  9. Quit the browser, reopen the app → the same catalog opens; the data folder holds the SQLite files.
  10. --verify with a renamed runtime/node → exit 3 and a dialog, not a silent failure.
  11. Path with spaces / non-ASCII in LUMINARY_DATA → starts and writes there.
  12. Gatekeeper: download the zip through a browser (quarantine flag), then follow README-macos.txt → one-time Open Anyway, then normal launches.
  13. On an Intel Mac: the same bundle runs (universal, both sharp slices).
  14. Optional: notarized build → double-click installs with no warning, spctl -a -vv -t exec Luminary.app says accepted.

Known limits

  • No Dock menu. The launcher exits once the browser opens; stopping is --stop / Stop Luminary.command, not a Quit menu item.
  • Ad-hoc signing is per-bundle. Copying the app with an archiver that drops extended attributes can make macOS call it damaged; the zip is made with ditto for that reason.
  • Universal builds install sharp twice (one npm ci per architecture) and copy the second slice's @img packages across; this is tested for layout, not for runtime, until both architectures are exercised.
  • Icon quality depends on the source. public/logo.png is 147×160, so the generated .icns is soft; pass --icon with a 1024×1024 PNG for a release.
  • No auto-update, no file associations, no login item. Same phase-2 list as Windows.