feat(deploy): proof-of-concept Maple Cloud self-host on celld - #689
feat(deploy): proof-of-concept Maple Cloud self-host on celld#689xesrevinu wants to merge 7 commits into
Conversation
ff5ec6b to
da18e48
Compare
|
Hey—I've just started trying maple recently, it's very interesting. Thank you for your continuous dedication; the daily experience is really great, and I will keep an eye on it. The one place I got stuck is running it on my own VPS. What I actually want is to keep the app on the machine and expose it through Cloudflare Tunnel, not to run it as Cloudflare Workers. Tunnel vs Workers is a different shape of “on Cloudflare,” and the current Cloud path is pretty tightly bound to the latter. So this draft is just a spike: same Worker source, celld as the runtime, origin sits on the VPS and can go out via a tunnel. The awkward bit is Postgres — celld doesn’t have Hyperdrive or working Totally a POC, not a “please merge this.” Figured I’d share the experiment in case the direction is interesting. |
|
One small note on product shape, since this is the Cloud stack rather than I know you’re building a business around hosted Maple, and I don’t want this to read as “here’s how to skip that.” Local-mode already covers self-host telemetry; this spike is just our VPS + tunnel case. If a recipe like this would get in the way of what you’re commercializing, totally fine to leave it as a draft or a fork — we’ll follow your lead ❤️. |
|
Hey, I think this is quite cool and would love to make Maple easier for self hosting! But don't want to commit something right now since I expect it to still change a lot, especially on the architecture side, which would make development quite a pain if I try to maintain parity for self hosters right now! But in general love the initiative here and it's deff something im really intersted in supporting a long the oad. |
|
😃 I completely understand that you are in a fast development phase, and this approach is just an interesting attempt. I believe that in the future, Achemy can provide a more convenient deployment method. I am also trying to integrate Maple into the product and will keep following Maple's excellent work. |
Run the Cloud Workers (api, electric-sync, alerting) and the web UI on celld instead of Cloudflare, so a VPS install does not need a CF account. celld cannot TCP-dial Postgres, so Postgres goes through a Neon-style WebSocket proxy; AES-GCM uses Web Crypto because celld node:crypto createCipheriv is inert. This is an experiment toward simpler self-hosting, not a replacement for alchemy deploy or local-mode maple start.
Ship Postgres/ClickHouse/Electric/OTel alongside the Workers, and run first boot as drizzle-kit + clickhouse-cli + db:ensure-electric-publication instead of SQL in a ConfigMap. Environment pins (nodeSelector, ingress) go in a Kustomize overlay. Default RUST_LOG=warn so celld stops emitting a ship-loop line every second.
api/sync/alerting wait for a one-shot migrate service that calls drizzle-kit, clickhouse-cli, and db:ensure-electric-publication. The example k8s overlay uses strategic merge so re-apply is idempotent.
Self-hosted has no ClerkProvider. Settings → Ingestion used useAuth via useGuidedFramework, which threw. Read org id from useActiveOrgId instead. schemaDiff returns an empty diff when BYO ClickHouse is not configured instead of 400.
GET /internal/billing/customer is 500 BillingNotConfiguredError without AUTUMN_SECRET_KEY. Self-hosted has no Stripe/Autumn; settings nav still subscribed useMapleCustomer. Disable the atom in that mode.
turbo prune the Worker graph, drop oxlint/alchemy/wrangler from the runtime, and apply Postgres migrations with drizzle-orm so the image does not need drizzle-kit. Co-Authored-By: Grok <grok@x.ai>
celld v0.4.1 can connect through cloudflare:sockets, so self-host uses the same postgres.js path as wrangler. Remove the Neon websocket fallback, proxy service, and deploy wiring that existed only for that gap.
8b92a9c to
f4fb331
Compare
Proof of concept — not a production proposal
This is an experiment in running Maple Cloud (the Workers API + web UI + electric-sync + alerting) on celld so a VPS can sit behind something like Cloudflare Tunnel without putting the app on Cloudflare Workers, and without Wrangler / Miniflare / Alchemy.
It is not:
alchemy deploy)maple start(telemetry-only single binary)The goal is to keep one Worker source (
wrangler.celld.jsoncis a stripped subset of the existing Wrangler config) instead of rewriting the API as a second Node/Express server.Postgres
celld v0.4.1 implements outbound TCP through
cloudflare:sockets. The Worker dials Postgres the same way Cloud does (postgres.jscfbuild, request-scoped pool). Hosted Workers still prefer theMAPLE_DBHyperdrive binding; celld has no Hyperdrive, so it usesMAPLE_PG_URL.There is no WebSocket sidecar. ClickHouse is already HTTP.
What this adds
bash scripts/celld-dev.sh— threecelld devprocesses (api / electric-sync / alerting) against docker Postgres + ClickHouse + Electric.deploy/celld-self-host/— Compose one-command stack, Caddy same-origin, Kustomize. Defaultdocker compose --env-file .env up --build→ http://127.0.0.1:8080. BYO Postgres/S3: copy the folder and delete those services.VITE_*URLs; Electric ShapeStream requires an absolute URL, so production resolveslocation.origin.node:cryptoHMAC works;createCipheriv("aes-256-gcm")does not. Stored{ciphertext,iv,tag}layout is unchanged.Other celld limits (v0.4.1)
wrangler keys
hyperdrive/ai/ratelimits/send_email/dev/workers_devabort deploy. Queues omitted (celld refuses a queue consumer on a Worker that also exportsfetch). Cron / DO / R2 are Partial.node:netis still unimplemented; sockets go throughcloudflare:socketsand die with the event.How to try it
Sign in at http://127.0.0.1:8080 with
MAPLE_ROOT_PASSWORD(docs examples usechange-me). Stop any localcelld-devstack first so 8080/4317 stay the default ports.First boot still needs Drizzle migrate + ClickHouse schema + Electric publication (same heal as
dev:celld).Relevant issues