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.

21 lines · 989 B · executableRaw History
1#!/bin/bash
2# Hosted Diffinery runners: starts the Docker daemon the first time anything needs
3# it (a step running `docker`, job containers, services, Docker actions), then runs
4# the real CLI. The daemon runs in its own session so step cleanup leaves it alone.
5real=/usr/bin/docker
6ready=/run/diffinery-dockerd.ready
7if [ ! -e "$ready" ] && [ -z "${DOCKER_HOST:-}" ] && [ "$(id -u)" = 0 ]; then
8 exec 9>/run/diffinery-dockerd.lock
9 flock 9
10 if [ ! -e "$ready" ]; then
11 if ! "$real" version >/dev/null 2>&1; then
12 echo "Starting the Docker daemon" >&2
13 env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin setsid -f dockerd >/var/log/dockerd.log 2>&1 </dev/null
14 for _ in $(seq 1 240); do "$real" version >/dev/null 2>&1 && break; sleep 0.25; done
15 "$real" version >/dev/null 2>&1 || { echo "The Docker daemon did not start:" >&2; tail -n 20 /var/log/dockerd.log >&2; exit 1; }
16 fi
17 touch "$ready"
18 fi
19 exec 9>&-
20fi
21exec "$real" "$@"