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.

67 lines · 2.9 KBRaw History
1name: Docker in Cloudflare Containers
2
3# Checks whether a Cloudflare Container can run a Docker daemon (rootful or
4# rootless), so hosted Diffinery runners can offer Docker. Deploys a throwaway
5# probe Worker with a container, prints what worked, and removes it.
6# Uses the repository secrets CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
7on:
8 workflow_dispatch:
9
10permissions:
11 contents: read
12
13jobs:
14 probe:
15 name: Probe Docker inside a container
16 runs-on: ubuntu-latest
17 timeout-minutes: 40
18 env:
19 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
20 CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
21 NAME: diffinery-dind-probe-${{ github.run_id }}
22 steps:
23 - uses: actions/checkout@v4
24 - uses: pnpm/action-setup@v4
25 - uses: actions/setup-node@v4
26 with:
27 node-version: 22
28 cache: pnpm
29 - run: pnpm install --frozen-lockfile
30 - name: Deploy the probe
31 working-directory: apps/diffinery/scripts/dind-probe
32 run: |
33 set -euo pipefail
34 cat > wrangler.json <<JSON
35 {"name":"$NAME","main":"worker.js","compatibility_date":"2026-10-01","workers_dev":true,
36 "containers":[{"class_name":"Probe","image":"./Dockerfile","instance_type":"standard-2","max_instances":1}],
37 "durable_objects":{"bindings":[{"name":"PROBE","class_name":"Probe"}]},
38 "migrations":[{"tag":"v1","new_sqlite_classes":["Probe"]}]}
39 JSON
40 pnpm --dir "$GITHUB_WORKSPACE/apps/diffinery" exec wrangler deploy -c "$PWD/wrangler.json"
41 sub=$(curl -sS "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/workers/subdomain" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | jq -r '.result.subdomain // empty')
42 echo "PROBE_URL=https://$NAME.$sub.workers.dev" >> "$GITHUB_ENV"
43 - name: Run the probe
44 run: |
45 set -uo pipefail
46 for i in $(seq 1 60); do
47 curl -fsS -m 30 -o /dev/null "$PROBE_URL/run" && break
48 sleep 10
49 done
50 for i in $(seq 1 120); do
51 out=$(curl -sS -m 30 "$PROBE_URL/log")
52 grep -q "PROBE DONE" <<<"$out" && break
53 sleep 10
54 done
55 echo "$out"
56 echo "::group::Summary"
57 grep '^RESULT' <<<"$out" | tee -a "$GITHUB_STEP_SUMMARY"
58 echo "::endgroup::"
59 - name: Remove the probe
60 if: always()
61 working-directory: apps/diffinery/scripts/dind-probe
62 run: |
63 W=(pnpm --dir "$GITHUB_WORKSPACE/apps/diffinery" exec wrangler)
64 [ -f wrangler.json ] && "${W[@]}" delete -c "$PWD/wrangler.json" --force || true
65 for id in $("${W[@]}" containers list --json 2>/dev/null | jq -r --arg n "$NAME" '.[] | select(.name | startswith($n)) | .id'); do
66 "${W[@]}" containers delete "$id" -c "$PWD/wrangler.json" || true
67 done