Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
128 lines (123 loc) · 5.74 KB
/
Copy pathdocker-compose.yml
File metadata and controls
128 lines (123 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# RUNNERS ephemeral runners, CONTROL_RUNNERS coordination runners and a
# `pruner` for maintenance. Size a host by setting RUNNERS in .env
# (hosts/sizing.sh suggests a value); there is nothing per runner to copy.
#
# State lives in one host directory, RUNNER_DATA_DIR, bind-mounted at the SAME
# path inside every container. On start each container claims a free slot,
# RUNNER_DATA_DIR/slots/<id>, with a lock it holds for its whole life (see
# preflight-entrypoint.sh), and keeps its work dir and caches there:
# slots/<id>/work RUNNER_WORKDIR. The same path on the host, so the
# `docker run -v` / container actions a job hands
# to the host daemon see the checkout (issue #19).
# slots/<id>/cache/<store> bun, npm, pnpm, gradle, cargo, rustup, konan,
# mise, hk, pub and the hosted tool cache; the
# default home paths (/root/.bun, ...) link here.
# One slot per running container, so no two concurrent jobs share a cache.
# The action archive cache is the only shared state: read-only in the
# runners, filled by the pruner.
x-runner-env: &runner-env
APP_ID: ${APP_ID}
APP_PRIVATE_KEY: ${APP_PRIVATE_KEY}
APP_LOGIN: ${APP_LOGIN}
RUNNER_NAME_PREFIX: ${RUNNER_NAME_PREFIX:-runner}
RUNNER_SCOPE: org
ORG_NAME: ${APP_LOGIN}
LABELS: ${LABELS:-docker}
RUNNER_GROUP: ${RUNNER_GROUP:-Default}
RUNNER_DATA_DIR: ${RUNNER_DATA_DIR:-/var/lib/github-runner}
RUNNER_CACHES: ${RUNNER_CACHES:-on}
# The upstream entrypoint only tests these with `[ -n "$VAR" ]`, so ANY
# non-empty value - including "false" - turns the flag on.
#
# Each runner takes exactly one job, deregisters, exits, and
# `restart: unless-stopped` starts it again to register afresh. The slot's
# caches carry over; /tmp and the job's leftovers do not (cleanup.sh).
EPHEMERAL: "true"
# Empty (the default) leaves runner self-update on. Set it in .env to ANY
# non-empty value to disable updates; `DISABLE_AUTO_UPDATE=false` disables
# them too. See .env.example.
DISABLE_AUTO_UPDATE: ${DISABLE_AUTO_UPDATE:-}
# Ephemeral runners re-download every action archive for every job, and the
# few public IPs of these hosts hit codeload.github.com's 429 limit. The
# runner (>= 2.319) reads <dir>/<owner>_<repo>/<sha>.tar.gz before it
# downloads, and only reads: the `pruner` service fills the shared
# runner-action-cache volume (see pruner.sh), mounted read-only below.
ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE: /opt/actionarchivecache
x-runner: &runner
image: ${RUNNER_IMAGE:-ghcr.io/dodi-smart/github-runner}
restart: unless-stopped
# .env is passed whole, so RUNNER_<id>_LABELS works for any slot id without
# listing each one here. Optional, so `docker compose config` runs without it.
env_file:
- path: .env
required: false
environment: *runner-env
# Optional per-runner limits (hosts/sizing.sh suggests them; 0 = none). With
# a CPU limit the preflight sizes Gradle/cargo/make/cmake parallelism to it,
# so runners sharing a host don't each spawn a worker per host CPU.
cpus: ${RUNNER_CPUS:-0}
mem_limit: ${RUNNER_MEMORY:-0}
# Runner.Listener is the long-lived process of a registered runner. Exec form
# on purpose: under CMD-SHELL the wrapping `sh -c` carries the pattern in its
# own command line and `pgrep -f` would match itself, healthy forever. The
# container restarts after every job (ephemeral), so start_period covers
# re-registration.
healthcheck:
test: ["CMD", "pgrep", "-f", "Runner.Listener"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${RUNNER_DATA_DIR:-/var/lib/github-runner}:${RUNNER_DATA_DIR:-/var/lib/github-runner}
- runner-action-cache:/opt/actionarchivecache:ro
security_opt:
- label:disable
services:
# Slots 1..RUNNERS. Each registers with the host's LABELS, or with
# RUNNER_<id>_LABELS when that is set: one runner of a host can then join
# another pool (a `large` runner on a host whose others stay `light`).
runner:
<<: *runner
deploy:
replicas: ${RUNNERS:-3}
# Coordination runners carry only CONTROL_LABELS (default `control`), never a
# work label, so no build or test can land on them: they exist so the short
# jobs a merge waits on (a picker, a required summary) never queue behind long
# work. Those jobs read the API and check nothing out, so they get no
# docker.sock and no tool caches (slots c1..cN, work dir only).
control:
<<: *runner
deploy:
replicas: ${CONTROL_RUNNERS:-0}
environment:
<<: *runner-env
LABELS: ${CONTROL_LABELS:-control}
RUNNER_NAME_PREFIX: ${RUNNER_NAME_PREFIX:-runner}-control
RUNNER_SLOT_PREFIX: c
RUNNER_CACHES: "off"
volumes:
- ${RUNNER_DATA_DIR:-/var/lib/github-runner}:${RUNNER_DATA_DIR:-/var/lib/github-runner}
- runner-action-cache:/opt/actionarchivecache:ro
# Maintenance off the job path (pruner.sh): cache budgets per slot and docker
# prune, plus the hourly action-cache fill.
pruner:
image: ${RUNNER_IMAGE:-ghcr.io/dodi-smart/github-runner}
restart: unless-stopped
entrypoint: ["/usr/local/bin/pruner.sh"]
env_file:
- path: .env
required: false
# .env (env_file above) brings the App credentials it prefetches actions
# with and every pruner tunable.
environment:
RUNNER_DATA_DIR: ${RUNNER_DATA_DIR:-/var/lib/github-runner}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${RUNNER_DATA_DIR:-/var/lib/github-runner}:${RUNNER_DATA_DIR:-/var/lib/github-runner}
- runner-action-cache:/opt/actionarchivecache
security_opt:
- label:disable
volumes:
runner-action-cache: {} # read-only in runners, filled by the pruner