feat: fly.io provisioning IaC for server, postgres, redis and scylla - #308
Open
jeferson-sb wants to merge 1 commit into
Open
feat: fly.io provisioning IaC for server, postgres, redis and scylla#308jeferson-sb wants to merge 1 commit into
jeferson-sb wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expresses the
docker-compose.ymltopology as Fly.io IaC underinfra/fly/, as a POC — nothing is deployed, and the rootfly.toml(generated in 2022, before Redis/Postgres/Scylla existed) is deleted in favour of it.Four apps on one 6PN private network, rather than one app with process groups, since only the chat tier scales on connection count and each store needs its own image, volume and restart semantics:
chatmeinfra/fly/server/fly.tomlauto_stop_machines = "off"chatme-postgresinfra/fly/postgres/fly.tomlpostgres:17-alpine+ volumechatme-redisinfra/fly/redis/redis.confwithappendonly,maxmemory-policy noevictionchatme-scyllainfra/fly/scylla/Three decisions worth reading the ADR (
docs/adr/2026-08-18-fly-io-provisioning.md) for:Fly Proxy replaces nginx — it already terminates TLS and upgrades websockets, so
nginx.confhas no deployed counterpart. Concurrency istype = "connections"(soft 200 / hard 250), because a Socket.IO client holds one long-lived socket and request counts would describe nothing. No sticky sessions needed: websocket-only + Redis adapter.Scylla on an IPv6-only network is the non-obvious part. There is no stable per-node hostname, so
infra/fly/scylla/entrypoint.shderives seeds from DNS at boot before handing over to the image's entrypoint:It also sets
enable_ipv6_dns_lookup: trueand writesdc=$FLY_REGION, which is why the server'sSCYLLA_LOCAL_DATACENTERis the region string — a mismatch makes the driver see no local nodes.provision.shscales nodes one at a time so two never bootstrap an empty ring in parallel.Migrations run from the workstation over
fly proxy, not on release: the server image is built withpnpm install --prod, which prunes@better-auth/cliand the migrate scripts' dev deps.infra/fly/provision.shis the entrypoint — idempotent, step-selectable (./infra/fly/provision.sh server), and ordered stores → migrate → server, since the server exits at startup without a reachableDATABASE_URL. Secrets (BETTER_AUTH_SECRET,POSTGRES_PASSWORD,DATABASE_URL) are generated/wired by the script;REDIS_URLandSCYLLA_CONTACT_POINTSare plain.internalconfig. No store publishes a public port (ports = []).Known gaps (documented in
infra/fly/README.md)Single-node Postgres and Redis with no backups or replication; no
requirepasson Redis (6PN isolation only); RF=3SimpleStrategyassumes one region; TCP-only health checks until the server grows a/healthroute; machine sizes are starting points, not measurements.Verification
TOML parses and
shellcheckis clean.fly config validateneeds an authenticated token, so the configs have not been validated against Fly's schema, and nofly deploywas attempted.Link to Devin session: https://app.devin.ai/sessions/7aa1398f2dac44648da2cf63cda1a0f7