-
Notifications
You must be signed in to change notification settings - Fork 1.2k
290 lines (246 loc) · 8.98 KB
/
Copy pathdocker-service.yml
File metadata and controls
290 lines (246 loc) · 8.98 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Docker service images
on:
push:
branches-ignore:
- coverity_scan
workflow_dispatch:
env:
CI: 1
GH_ACTIONS: 1
DEBIAN_FRONTEND: noninteractive
APT_OPTS: "-y --no-install-recommends"
jobs:
#
# Generate matrix based on docker directories.
#
gen-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6
with:
lfs: false
- id: gen-matrix
name: Generate matrix based on docker targets
run: |
cd scripts/docker/build
M=$(ls | perl -n -e '{chomp; push @L,"\"$_\""} END{print "{\"env\":[{\"OS\":",join("},{\"OS\":",@L),"}]}"}')
echo "Matrix: $M"
echo matrix=$M >> $GITHUB_OUTPUT
#
# Self-hosted variant: runs on the FreeRADIUS Proxmox fleet inside
# the self-hosted-docker-cli image and talks to a self-hosted-docker-dind
# sidecar (registry-mirror -> internal NR cache, internal CA pre-trusted).
#
docker-selfhosted:
needs:
- gen-matrix
if: github.repository_owner == 'FreeRADIUS'
runs-on: self-hosted
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
env: ${{ matrix.env }}
name: "v4.0.x-${{ matrix.env.OS }}"
services:
dind:
#
# Custom dind image with /etc/docker/daemon.json baked in
# pointing at the internal NR registry as a Docker Hub
# pull-through mirror, and the internal CA pre-trusted.
#
image: docker.internal.networkradius.com/self-hosted-docker-dind
options: --privileged
env:
DOCKER_TLS_CERTDIR: ""
# Bypass the squid proxy for internal registry access.
NO_PROXY: "*.networkradius.com,127.0.0.1"
#
# Share the runner's workspace with dind so the build
# context (Dockerfile + COPY sources) resolves to real
# files inside the dind daemon.
#
# github.workspace is the HOST path to the workspace. The
# runner mounts it into the job container at a different
# path (/__w/...), so we use a fixed mount point
# (/workspace) that both containers agree on.
#
volumes:
- ${{ github.workspace }}:/workspace
container:
#
# Custom CI image with docker CLI / buildx / m4 baked on top
# of the self-hosted base.
#
image: docker.internal.networkradius.com/self-hosted-docker-cli
env:
DOCKER_HOST: tcp://dind:2375
NO_PROXY: dind,*.networkradius.com,127.0.0.1
# CA cert mount lets the in-container apt and curl talk HTTPS
# to docker.internal.networkradius.com. Shared workspace - see
# dind volumes comment above.
volumes:
- /usr/local/share/ca-certificates/networkradius.com.crt:/usr/local/share/ca-certificates/networkradius.com.crt:ro
- ${{ github.workspace }}:/workspace
defaults:
run:
working-directory: /workspace
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
lfs: false
- name: setup-dind
uses: ./.github/actions/setup-dind
#
# Authenticate dind to Docker Hub. self-hosted-docker-dind has
# registry-mirrors -> docker.internal.networkradius.com baked
# in, but our internal registry isn't actually a Hub pull-
# through cache, so FROM ubuntu:24.04 etc. inside the build
# falls back to docker.io and would otherwise hit anonymous
# rate limits.
#
- name: Login to Docker Hub (via dind)
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_READ_USER }}
password: ${{ secrets.DOCKERHUB_READ_KEY }}
#
# Authenticate dind to the internal registry so the push steps
# below can publish service + profiling images. The host docker
# daemon is logged in via the runner's job-started hook, but
# dind is a separate daemon with no auth config.
#
- name: Login to internal Docker registry (via dind)
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_REPO_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_REPO_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin https://docker.internal.networkradius.com/
- name: Verify Dockerfiles match m4 templates
run: |
make dockerfile.service.check
make dockerfile.profiling.check
#
# Build service + profiling images for this distro. Profiling
# FROMs the crossbuild image of the same distro, so its build
# rule depends on the crossbuild stamp - covered by the
# freeradius4-crossbuild push in docker-crossbuild.yml.
#
# DOCKER_REGISTRY is set so any base image (crossbuild) that
# hasn't yet been pulled locally is grabbed from the registry
# instead of rebuilt, per the pull-through fallback in
# scripts/docker/docker.mk.
#
- name: Build docker images
env:
DOCKER_REGISTRY: docker.internal.networkradius.com
run: |
make docker.service.$OS
make docker.profiling.$OS
#
# No push step here. service + profiling images are published as
# :latest by docker-refresh.yml on its periodic schedule. This
# workflow is a per-commit smoke build only - it confirms the
# Dockerfile chain still compiles. The built :<sha> tags die with
# the per-job dind sidecar.
- name: Show docker build log
if: failure()
run: |
cat build/docker/build.$OS.service 2>/dev/null || true
cat build/docker/build.$OS.profiling 2>/dev/null || true
#
# If the CI has failed and the branch is ci-debug then start a tmate
# session. SSH rendezvous point is emited continuously in the job output.
#
- name: "Debug: Start tmate"
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
if: ${{ github.ref == 'refs/heads/ci-debug' && failure() }}
#
# Public variant: runs on GitHub-hosted runners (fork pushes). Uses
# the public docker:dind sidecar and a plain ubuntu:24.04 job
# container - no internal registry or CA involvement.
#
docker-public:
needs:
- gen-matrix
if: github.repository_owner != 'FreeRADIUS'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
env: ${{ matrix.env }}
name: "v4.0.x-${{ matrix.env.OS }}"
services:
dind:
image: docker:dind
#
# No credentials: block here - this variant runs on fork CI
# where the org-level DOCKERHUB_READ_* vars/secrets aren't
# available, and a credentials: block with empty values fails
# workflow template validation. The host docker daemon does
# an anonymous pull of docker:dind here; GH-hosted runners
# have many egress IPs so the per-IP Hub limit is rarely an
# issue for fork builds.
#
options: --privileged
env:
DOCKER_TLS_CERTDIR: ""
# Share the runner's workspace with dind so the build
# context (Dockerfile + COPY sources) resolves to real
# files inside the dind daemon.
#
# github.workspace is the HOST path to the workspace. The
# runner mounts it into the job container at a different
# path (/__w/...), so we use a fixed mount point
# (/workspace) that both containers agree on.
volumes:
- ${{ github.workspace }}:/workspace
container:
image: ubuntu:24.04
env:
DOCKER_HOST: tcp://dind:2375
# Shared workspace — see dind volumes comment above.
volumes:
- ${{ github.workspace }}:/workspace
defaults:
run:
working-directory: /workspace
steps:
#
# actions/checkout falls back to a tarball download (no .git) when
# git isn't on PATH; the Dockerfile's `git clean -fdxx` then fails
# inside the build. ubuntu:24.04 ships without git, so install it
# before checkout. Harmless on the self-hosted CI image where git
# is already present.
#
- name: Ensure git is available for checkout
run: apt-get update && apt-get install -y --no-install-recommends git ca-certificates
- uses: actions/checkout@v6
with:
fetch-depth: 1
lfs: false
- name: setup-dind
uses: ./.github/actions/setup-dind
with:
packages: m4 make
- name: Verify Dockerfiles match m4 templates
run: make dockerfile.service.check
- name: Build docker image
run: |
make docker.service.$OS
- name: Show docker build log
if: failure()
run: cat build/docker/build.$OS.service
#
# If the CI has failed and the branch is ci-debug then start a tmate
# session. SSH rendezvous point is emited continuously in the job output.
#
- name: "Debug: Start tmate"
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
if: ${{ github.ref == 'refs/heads/ci-debug' && failure() }}