Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

126 lines · 6.4 KBRaw History
1// Diffinery: one Worker, everything on Cloudflare.
2// `scripts/bootstrap.sh` creates the account resources and writes
3// wrangler.deploy.jsonc (this file plus real IDs) for CI deploys.
4{
5 "$schema": "node_modules/wrangler/config-schema.json",
6 "name": "diffinery",
7 "main": "src/index.ts",
8 "compatibility_date": "2026-10-01",
9 "compatibility_flags": ["nodejs_compat"],
10 "workers_dev": false,
11 // A zone route, not a Custom Domain: diffinery.com already has DNS records, and a
12 // route runs the Worker in front of them as long as the record is proxied (orange cloud).
13 "routes": [{ "pattern": "diffinery.com/*", "zone_name": "diffinery.com" }],
14 "observability": { "enabled": true, "head_sampling_rate": 1 },
15 "upload_source_maps": true,
16 "limits": { "cpu_ms": 300000 },
17
18 "vars": {
19 "PUBLIC_URL": "https://diffinery.com",
20 "MAIL_FROM": "notifications@diffinery.com",
21 "BOOTSTRAP_ADMINS": "iletisim@canberkdemirci.com,canberkdemirci@icloud.com,iletisim@altugankarali.com",
22 "ACCESS_TEAM_DOMAIN": "",
23 "ACCESS_AUD": ""
24 },
25
26 "d1_databases": [
27 { "binding": "DB", "database_name": "diffinery", "database_id": "00000000-0000-0000-0000-000000000000", "migrations_dir": "migrations" }
28 ],
29 "r2_buckets": [{ "binding": "BUCKET", "bucket_name": "diffinery-data" }],
30 "queues": {
31 "producers": [
32 { "binding": "EVENTS", "queue": "diffinery-events" },
33 { "binding": "MAIL", "queue": "diffinery-mail" }
34 ],
35 "consumers": [
36 { "queue": "diffinery-events", "max_batch_size": 50, "max_batch_timeout": 2, "max_retries": 8, "dead_letter_queue": "diffinery-events-dlq" },
37 { "queue": "diffinery-mail", "max_batch_size": 20, "max_batch_timeout": 2, "max_retries": 8, "dead_letter_queue": "diffinery-mail-dlq" }
38 ]
39 },
40 // Cloudflare Email Sending (notifications, security alerts, invites). The sending
41 // domain is onboarded under Compute > Email Service > Email Sending (see scripts/email-sending.sh).
42 "send_email": [{ "name": "EMAIL" }],
43 "durable_objects": {
44 "bindings": [
45 { "name": "REPO", "class_name": "RepoDO" },
46 { "name": "SCHEDULER", "class_name": "SchedulerDO" },
47 { "name": "RUNNER", "class_name": "RunnerContainer" },
48 { "name": "SANDBOX", "class_name": "SandboxContainer" },
49 { "name": "IMPORTER", "class_name": "ImportContainer" },
50 { "name": "PROJECT", "class_name": "ProjectDO" }
51 ]
52 },
53 "migrations": [
54 { "tag": "v1", "new_sqlite_classes": ["RepoDO", "RunnerContainer", "SandboxContainer"] },
55 { "tag": "v2", "new_sqlite_classes": ["ImportContainer"] },
56 // Agent tasks, one Durable Object per repository (agentic/ProjectDO.ts).
57 { "tag": "v3", "new_sqlite_classes": ["ProjectDO"] },
58 // Workflow schedules (scheduler.ts).
59 { "tag": "v4", "new_sqlite_classes": ["SchedulerDO"] }
60 ],
61 "workflows": [
62 { "name": "diffinery-run", "binding": "RUN_WORKFLOW", "class_name": "RunWorkflow" },
63 { "name": "diffinery-import", "binding": "IMPORT_WORKFLOW", "class_name": "ImportWorkflow" }
64 ],
65 // A deploy that changes the image rolls the running containers: once a container has been up
66 // longer than rollout_active_grace_period seconds, it gets SIGTERM and is killed 15 minutes later.
67 // Runner and import containers are covered for their whole life (a job is capped at 6 hours, an
68 // import transfer too), so a deploy never cuts one short; they pick up the new image next start.
69 "containers": [
70 { "class_name": "RunnerContainer", "image": "../../containers/runner/Dockerfile", "image_build_context": "../../containers/runner", "instance_type": "standard-2", "max_instances": 100, "rollout_active_grace_period": 23400 },
71 { "class_name": "SandboxContainer", "image": "../../containers/runner/Dockerfile", "image_build_context": "../../containers/runner", "instance_type": "standard-1", "max_instances": 50, "rollout_active_grace_period": 3600 },
72 // GitHub imports: a mirror clone of a large repository needs disk and memory.
73 { "class_name": "ImportContainer", "image": "../../containers/runner/Dockerfile", "image_build_context": "../../containers/runner", "instance_type": "standard-4", "max_instances": 20, "rollout_active_grace_period": 25200 }
74 ],
75 // Housekeeping, and a check that the workflow scheduler's alarm is set (src/scheduler.ts).
76 "triggers": { "crons": ["*/5 * * * *"] },
77
78 "env": {
79 // Local development and end-to-end tests: no Access, a fixed dev identity, no containers.
80 "dev": {
81 "routes": [],
82 "workers_dev": true,
83 "vars": {
84 "PUBLIC_URL": "http://localhost:8787",
85 "MAIL_FROM": "notifications@diffinery.com",
86 "BOOTSTRAP_ADMINS": "dev@diffinery.local",
87 "ACCESS_TEAM_DOMAIN": "",
88 "ACCESS_AUD": "",
89 "DEV_AUTH": "dev@diffinery.local",
90 // Containers do not run under wrangler dev: an import agent started by hand (or by the e2e test) claims Git transfers.
91 "IMPORT_GIT_AGENT": "external"
92 },
93 "d1_databases": [{ "binding": "DB", "database_name": "diffinery-dev", "database_id": "00000000-0000-0000-0000-000000000000", "migrations_dir": "migrations" }],
94 "r2_buckets": [{ "binding": "BUCKET", "bucket_name": "diffinery-data-dev" }],
95 "queues": {
96 "producers": [
97 { "binding": "EVENTS", "queue": "diffinery-events-dev" },
98 { "binding": "MAIL", "queue": "diffinery-mail-dev" }
99 ],
100 "consumers": [
101 { "queue": "diffinery-events-dev", "max_batch_size": 50, "max_batch_timeout": 1 },
102 { "queue": "diffinery-mail-dev", "max_batch_size": 20, "max_batch_timeout": 1 }
103 ]
104 },
105 // Local email: Miniflare captures sent messages instead of delivering them.
106 "send_email": [{ "name": "EMAIL" }],
107 "durable_objects": {
108 "bindings": [
109 { "name": "REPO", "class_name": "RepoDO" },
110 { "name": "SCHEDULER", "class_name": "SchedulerDO" },
111 { "name": "RUNNER", "class_name": "RunnerContainer" },
112 // Sandboxes run in an `agent.mjs --sandbox-pool` process (SANDBOX_POOL_URL), not containers.
113 { "name": "SANDBOX", "class_name": "SandboxPoolDO" },
114 { "name": "IMPORTER", "class_name": "ImportContainer" },
115 { "name": "PROJECT", "class_name": "ProjectDO" }
116 ]
117 },
118 "workflows": [
119 { "name": "diffinery-run-dev", "binding": "RUN_WORKFLOW", "class_name": "RunWorkflow" },
120 { "name": "diffinery-import-dev", "binding": "IMPORT_WORKFLOW", "class_name": "ImportWorkflow" }
121 ],
122 "triggers": { "crons": [] },
123 "containers": []
124 }
125 }
126}