Deployment
A Reaktor product runs in many places at once. BestBuds, the production app built on Reaktor, has Android and iOS clients, a web client, an API on Cloudflare Workers and Durable Objects, and JVM services on a small Kubernetes cluster. Each runtime keeps its own proven tool underneath (wrangler, Kubernetes, Fastlane), and the build declares all of them in one place. You deploy through Gradle tasks that first write a plan and then apply exactly that plan.
Overview#
| Part | Where it runs | How it ships |
|---|---|---|
| Mobile apps | Android and iOS devices | Fastlane lanes to the stores and to Firebase App Distribution |
| Web app and these docs | Cloudflare Workers with static assets | A Gradle deploy task per Worker, planned and then applied |
| API and realtime services | Cloudflare Workers, Durable Objects, Queues, D1 and R2 | The same Gradle deploy tasks |
| Transactional data | Postgres, reached from Workers through Hyperdrive | Schema migrations in the repository |
| JVM services, Memgraph and ClickHouse | k3s on a Google Compute Engine VM, reached from Workers over a private tunnel | Container images and Kubernetes manifests |
| Grafana | A Cloudflare Container at telemetry.reaktor.build that sleeps when idle | Its own Worker deploy task |
Observe and diagnose covers the signals each part sends, where they are kept, and how to work through a problem.
The delivery block#
The build script declares what can be released and what has to happen first. This is the shape of the BestBuds declaration, shortened:
val schema by migrate(BestBudsDatabases.Main)
val clickhouse by migrate(BestBudsDatabases.ClickHouse, kubeconfig = BestBudsOptions.ServerKubeconfig)
delivery(after = pr, run = Run.onMac()) {
val playInternal by release(androidReleaseBundle, AndroidLane.PlayInternal) { require(BestBudsOptions.DevTools, false) }
val testflightInternal by release(releasePlan, IosLane.TestflightInternal) { require(BestBudsOptions.DevTools, false) }
val workers by deploy(projects.workers, run = Run.onLinux().onWorker())
workers.after(clickhouse)
val server by server(output(projects.reaktorServer, OutputKind.ServerArchive), environment = Environment("prod"))
server.after(schema, clickhouse)
}
delivery(after = pr)makes every release and deploy wait for theprcheck suite: the Reaktor framework checks, JVM and JS tests, architecture checks and a credential containment check.migratedeclares a database migration. Workers deploy after the ClickHouse migrations, and the server after both the Postgres schema and ClickHouse.releasedeclares a Fastlane lane for a store or Firebase App Distribution. Release lanes require a build with DevTools turned off.deploydeclares the Worker fleet, andserverthe JVM server image and its Kubernetes rollout.
Dependeasy is the Gradle plugin that turns these declarations into tasks. It also supplies the shared Worker settings, such as the Cloudflare account and the nodejs_compat flag, so individual wrangler.json files stay small.
Plan, then apply#
Every Worker deploy task runs in two steps. Run the ReaktorWeb tasks from the services build.
./gradlew --no-daemon :workers:deployReaktorWeb -Pdependeasy.deployAction=plan
./gradlew --no-daemon :workers:deployReaktorWeb
The plan step builds and bundles the Worker, reads the live version from Cloudflare, and writes a plan under build/dependeasy/plans/deploy/ that lists every difference in bindings and settings. The apply step uploads the planned bundle and nothing else. It refuses to run when the bundle or assets changed after planning, or when someone else deployed a new live version in between. In both cases nothing goes live, and you plan again.
A D1 migration applies only with a reviewed plan, even when the plan shows nothing pending. Plan and apply run the full gate by default. Skipping the gate (-x :pr) or the included BestBuds ClickHouse migrations (-x :bestbuds:clickhouse) requires the release owner's decision.
Receipts and rollback#
Each deploy step writes a receipt to build/dependeasy/receipts/deploy/<run>.json. A receipt records the action, the Git commit, the plan and artifact digests, the live version it produced, the version to roll back to, and the result. The run id also appears as the message on the Cloudflare deployment, so you can match a live version to the commit and plan that produced it:
pnpm exec wrangler deployments list --config wrangler.dependeasy-prod.json
To roll back a Worker, pass the version the receipt names as its rollback target to wrangler rollback with the same configuration file.
Other runtimes#
| Runtime | Artifact | How it ships |
|---|---|---|
| JVM server | Container image | Artifact Registry, then a rolling update on k3s |
| Cluster infrastructure | Helm releases and manifests | ../infra/k3s/observability/deploy.sh installs the observability stack: Prometheus, Loki, Tempo and Alertmanager from manifests, Alloy and kube-state-metrics from Helm charts |
| Android | App bundle | Fastlane lanes to Firebase App Distribution and Google Play |
| iOS | Release build | Fastlane lanes to Firebase App Distribution, TestFlight and the App Store |
| Grafana | Container image and Worker | :workers:deployTelemetry, plan then apply |
The build and test pipeline is the Gradle graph itself, so ./gradlew pr runs the same checks on a laptop and on the build worker. Hangar's Deploy pane shows the same tasks and recipes, runs them through the shared process supervisor and keeps their output. A production deploy from the pane needs a typed confirmation, and a destructive cloud change needs a second person to approve it.
Design: deploying a graph#
Today each runtime deploys separately, and the order between them comes from the delivery block. The design goes further: because a Reaktor app is one typed graph, a deploy can be an operation on that graph. None of the following is built yet.
- One platform model. A Kotlin
Platformdeclaration would generate the Worker configuration, Kubernetes manifests and provider API calls, instead of each being maintained by hand. - Deploy by partition. The deploy step would colour each node by the runtime it targets and ship each part through its own tool. Where a cut separates two nodes, it would insert the connecting piece: a network call between a Worker and the server, or a native call through FFI. A feature that touches a Worker, a server handler and a D1 table would ship as one ordered change.
- Blast radius from edges. Every dependency is an edge, so "what could this deploy break" becomes a graph traversal shown before you confirm.
- Drift. What was declared and what is running would be compared continuously, and the difference shown in the graph.
- Gated operations. Deploy, roll back, restart, scale, drain and migrate would be typed operations on the node they act on, with permission checks, blast radius and an audit record, so an agent can run them under the same rules as a person.
- Capacity. Creating, resizing and draining cluster cells would use the same operations, both for clusters Reaktor runs and for clusters a customer owns and attaches.
The executors stay the same: wrangler, the provider APIs, Kubernetes and Fastlane do the provisioning and shipping, and Reaktor decides what to ship, in which order, and with what checks.
What it improves#
| The usual approach | What goes wrong | What Reaktor does |
|---|---|---|
Running wrangler deploy by hand from a working folder | A failed build or the wrong configuration goes live, because nothing ties the upload to a checked build | A Gradle task builds, bundles and plans first, and the apply uploads exactly the planned bundle |
| Keeping the deploy order in people's heads | Code reaches production before the migration it needs | The delivery block declares the order: Workers after the ClickHouse migrations, the server after the Postgres schema and ClickHouse |
| Deploying without a record | Nobody can say which commit and plan made the live version, or what to roll back to | A receipt per step, and the run id as the message on the Cloudflare deployment |
| Two people deploying the same Worker at once | One silently overwrites the other | The apply refuses when the live version changed after planning |
Limitations#
- The gate is the whole
prsuite. In a shared checkout, other people's unfinished work can keep the suite red and block every deploy. Skipping the gate (-x :pr) or the ClickHouse migrations (-x :clickhouse) is a decision for the owner of the release. - Plan and apply must see the same files. Anything that rebuilds the bundle or its assets between the two steps makes the apply refuse, and you plan again.
- Every runtime still deploys on its own. The order between them comes from the delivery block; deploying a graph as one operation is a design, described above, and none of it is built.
Reference#
- The declarations: the
deliveryblock in BestBuds' rootbuild.gradle.kts, and the shared Worker settings inbuildSrc(BestBudsDelivery.kt). - Plans and receipts:
build/dependeasy/plans/deploy/andbuild/dependeasy/receipts/deploy/in the BestBuds checkout. - Related pages: Dependeasy for the Gradle plugin, Cloud pane for deploys from Hangar, Observe and diagnose, and Shadow for checking a change against a copy of production first.