feat(self-host): add configurable services and client packaging
What & why
Add opt-in self-host service adapters for native PostgreSQL, Redis, SMTP and S3-compatible storage, durable queue/scheduler services, Authentik sign-in, optional analytics, configurable service origins and local desktop/CLI/iOS packaging. Managed-provider defaults and retained PostgreSQL 17 installations continue to work.
- Native DB operations use the direct unpooled connection and normalize driver results in maintenance scripts. Durable queue publication acknowledges committed storage; four draining workers refill freed slots, and fenced leases reject stale acknowledgements.
- Private pages/files and public images use separate buckets. Image replacement saves before reclaiming old content, awaits cleanup, and limits deletion concurrency. Retained Garage keys must match supplied credentials before policy reconciliation.
- Worker configuration validates origins and matching ticket secrets, rejects output/template aliases, and writes private atomic configuration. Docker contexts exclude real credential/state files while retaining tracked dummy templates. Configurable runtime bases explicitly support Debian Node 24.
- Authentik actions follow actual provider availability on web, desktop and mobile; mobile Apple entitlement uses the same selection. Sign-in scrolls, analytics opt-out stays quiet, and configured SDK flags preserve their behavior. Unconfigured billing makes no Stripe calls, including with retained customer IDs, while configured billing/lifecycle behavior is preserved.
- Packaging checks runtime/dependency closure, target compatibility, nonempty essential executables/addons/migrations, Windows/POSIX containment and fully drained child output. Runtime secrets do not invalidate unrelated build caches; public output settings affect their relevant builds.
- A faithful three-file Bun backport of Expo’s official fix #51040 corrects the pinned ExpoModulesJSI 57.1.1 Swift interop: private constructors, explicitly retained factories and pointer-capture wrappers preserve existing ownership.
#8231 supplies configured desktop upload origins. #8233’s PostgreSQL 18 development switch is independent. Composition with #8235 retains both optional providers and schedules GitLab hook reconciliation. Selecting an adapter does not transfer a live store: retain the prior configuration and data for rollback. Native queue delivery is at least once.
One commit based on upstream 2dda82c314606aaa099b8626150c61450d66b629. Final candidate: 97aaeb4ea39e09f70f021743fe6417cb50be6049. Related review: tracking issue #8241.
The one-commit combined source on review/verified-composition-20261007 (ef1ac91f) integrates all seven proposals for reproduction without another PR. Shared graph evidence applies to that composition; focused proposal checks are recorded separately.
How I tested it
Actual native PostgreSQL exports passed query, commit, rollback and advisory-lock serialization checks; the combined-source DB package run passed 35 cases/212 assertions with no skips. Actual pinned Garage v2 checks passed new/retained credentials, mismatch refusal and key rotation. The candidate usercontent image built in 49.4 seconds and ran as UID 1001; its real Worker/Garage fixture passed all three page/ticket/file-range cases and 49 assertions. All seven owned resources were verified removed.
Actual pinned Valkey acceptance passed seven cases/69 assertions with no skips or failures in 427 ms. Five native cases made zero HTTP requests and verified Upstash-compatible serialization, TTL, conditional set, GET/delete, 16 concurrent reads/writes and NOSCRIPT recovery; 12 rate-limit calls admitted exactly three. Two managed-provider cases also passed. The disposable container was removed.
The genuine installed Expo package passed one native case/19 assertions: Swift header import, C++ dispatch/retain-release, and copied Swift factory references surviving their original scope under -Onone and -O with AddressSanitizer. A deliberately unretained-factory control failed the ownership assertion; production retain/release bodies were unchanged.
Actual adapter and lifecycle fixtures cover DB result shapes, queue refill/lease recovery, storage commands/cleanup, disabled/configured billing, auth actions and SDK flags. Docker context positive/negative controls verified 15 excluded sentinels and eight retained files/templates. Real Turbo hash comparisons, child-output drainage and packaging refusal fixtures passed. The PostgreSQL 17→18 transfer rehearsal is recorded in #8233. Final focused proposal checks: Final combined graph: all 42 compiler/declaration/catalog tasks passed; full lint passed 9,927 files. Exact self-host candidate Docker build and real Garage/Worker acceptance passed three cases/49 assertions; all seven owned resources were removed. Actual native PostgreSQL query/transaction/lock cases, Valkey native/managed cases, queue/storage/billing/provider fixtures and real Swift/ASan ownership checks passed. The source-only composition linked in #8241 reproduces shared optional-provider contracts..
24 original app captures and review evidence. The source-based service diagram and detailed adapter evidence are in the self-host overview; #8241 records the shared evidence boundaries.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (final candidate scope/results above) - "Allow edits from maintainers" is checked on fork PRs
Summary by CodeRabbit
- New Features
- Added self-hosted deployment options for databases, queues, Redis-compatible storage, email, and S3-compatible object storage.
- Added optional Authentik sign-in across web, desktop, and mobile.
- Added configurable download and update feeds for the desktop app and CLI, with CLI download integrity checks.
- Added mobile build configuration for app identity, updates, and signing.
- Added standalone build options and expanded setup guides for self-hosted services and client releases.
- Improvements
- Analytics can be left unconfigured without preventing app startup.
- Improved desktop packaging validation and workspace image handling.