Repository navigation
254 lines (232 loc) · 11.5 KB
/
Copy path_docker.yaml
File metadata and controls
254 lines (232 loc) · 11.5 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
name: Docker
# Default least-privilege permissions for the workflow. Individual jobs
# below raise to write where they actually need it (image push to GHCR).
# Closes Scorecard TokenPermissionsID #514.
permissions:
contents: read
on:
workflow_call:
inputs:
ref:
description: Git ref to check out (branch, tag, or sha). Empty uses the default.
required: false
type: string
default: ''
server_version:
required: true
type: string
prerelease:
required: false
type: boolean
default: false
tag_suffix:
description: >-
Custom tag suffix for builds that must NOT touch the shared tags —
experimental / workshop / hotfix branches. When set, the image is
published ONLY as <version>-<suffix> and `latest` is deliberately
skipped, so a branch build cannot become what everything else
resolves to. Empty preserves the previous behaviour exactly.
required: false
type: string
default: ''
jobs:
docker:
name: ${{ inputs.prerelease && 'Publish Docker prerelease image' || 'Publish Docker image' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# Required for cosign keyless signing via Sigstore (GitHub OIDC).
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ inputs.ref }}
# `github.sha` is the workflow-file's trigger SHA, not necessarily the
# commit checked out above (e.g. prerelease.yaml passes a workflow_run
# head_sha as `ref`). Resolve the actual checked-out commit instead, so
# the label always matches what was built. See #1759.
- name: Resolve checked-out commit SHA
id: revision
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Download server artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: server-artifacts-ubuntu
path: release-assets
- name: Download node archive
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: server-artifacts-nodes
path: dist/nodes
- name: Extract server
run: |
mkdir -p dist/server
tar xf release-assets/rocketride-server-*-linux-x64.tar.gz -C dist/server
if [ ! -f dist/server/engine ]; then
echo "::error::Engine binary not found after extraction"
ls -la dist/server/
exit 1
fi
# The node image is ~6 GB unpacked, and buildx keeps its own copy while
# building: the runner's root filesystem cannot hold both. /mnt can.
- name: Move Docker's data to /mnt
run: |
set -euo pipefail
sudo mkdir -p /mnt/docker
conf=/etc/docker/daemon.json
{ sudo cat "$conf" 2>/dev/null || echo '{}'; } | jq '. + {"data-root": "/mnt/docker"}' | sudo tee "$conf.new" >/dev/null
sudo mv "$conf.new" "$conf"
sudo systemctl restart docker
docker info --format 'docker data in {{.DockerRootDir}}'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Log in to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The base the engine image (and the node image) is built FROM. Published
# under the same tag rules, so a pulled engine-base matches its engine.
# Its build runs the engine, so a tree without its runtime libs stops here.
- name: Build and push engine-base
id: base
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: docker/Dockerfile.engine-base
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository_owner }}/rocketride-engine-base:${{ inputs.server_version }}${{ inputs.tag_suffix != '' && format('-{0}', inputs.tag_suffix) || (inputs.prerelease && '-prerelease' || '') }}
labels: |
org.opencontainers.image.revision=${{ steps.revision.outputs.sha }}
- name: Build and push
id: build
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: docker/Dockerfile.engine
build-args: |
ENGINE_BASE=ghcr.io/${{ github.repository_owner }}/rocketride-engine-base@${{ steps.base.outputs.digest }}
push: true
platforms: linux/amd64
# Three mutually exclusive shapes, in priority order:
# tag_suffix set -> <version>-<suffix> and NO latest
# prerelease true -> <version>-prerelease and no latest
# otherwise -> <version> and latest
# The suffix wins over `prerelease` on purpose: a suffixed build is
# by definition one that must not land on a shared tag, and that
# intent should not depend on the caller also getting `prerelease`
# right. `latest` is withheld for the same reason — an experimental
# branch silently becoming `latest` is the worst outcome available.
tags: |
ghcr.io/${{ github.repository_owner }}/rocketride-engine:${{ inputs.server_version }}${{ inputs.tag_suffix != '' && format('-{0}', inputs.tag_suffix) || (inputs.prerelease && '-prerelease' || '') }}
${{ (inputs.prerelease == false && inputs.tag_suffix == '') && format('ghcr.io/{0}/rocketride-engine:latest', github.repository_owner) || '' }}
labels: |
org.opencontainers.image.revision=${{ steps.revision.outputs.sha }}
# The image is built, pushed and signed — but until this step nothing
# ever STARTED it. Three broken images reached the registry that way:
# onnxruntime-gpu==1.20.1 unsatisfiable (#1754), the runtime install set,
# and "No module named 'jwt'" (#1828). Each exited within ~60s of
# `docker run`, and each was found by someone pulling `latest`.
#
# Our own deployments never caught them: the cloud image is assembled
# differently and its extension happens to supply what the engine forgets
# to declare. "It works for us" is therefore not evidence about the
# artefact we publish. This step runs the artefact.
#
# Deliberately BEFORE signing — a container that cannot start should not
# acquire a signature.
- name: Smoke test — the published image must start
env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/rocketride-engine
run: |
set -u
# -i is load-bearing: with no stdin the engine's watcher thread
# busy-polls /dev/null and pins a core (diagnosed in saas #280).
docker run -d -i --name rr-smoke -p 5565:5565 "${IMAGE}@${DIGEST}"
fail() {
echo "::error::$1"
echo "----- docker logs -----"
docker logs rr-smoke 2>&1 | tail -100
docker inspect rr-smoke --format 'exit={{.State.ExitCode}} oom={{.State.OOMKilled}} err={{.State.Error}}'
exit 1
}
# Failure mode one: the process dies. All three known breakages look
# like this and they show up fast.
for _ in $(seq 1 36); do
running=$(docker inspect -f '{{.State.Running}}' rr-smoke 2>/dev/null || echo false)
if [ "$running" != "true" ]; then
fail "Container exited before serving — the crash-on-start class."
fi
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 http://127.0.0.1:5565/version 2>/dev/null || echo 000)
if [ "$code" = "200" ]; then
echo "Engine answered /version with HTTP 200 — healthy."
docker rm -f rr-smoke >/dev/null 2>&1 || true
exit 0
fi
# A non-200 is not success: 000 = unreachable (still starting), and
# a 4xx/5xx from a half-started engine is exactly the broken-image
# case this gate must CATCH, not wave through. Keep polling for a
# real 200 until the deadline below.
[ "$code" != "000" ] && echo " /version returned HTTP $code — not ready yet"
sleep 5
done
# Alive but never served. Not one of the known three, but a wedged
# engine reads as healthy to a TCP probe (saas #461), so fail rather
# than assume it is merely slow.
fail "Running but never returned 200 from /version within ~180s (last code: $code)."
# Cosign keyless signing via GitHub OIDC. Signs the image manifest by
# digest, which covers every tag pointing at it. Verification:
# cosign verify ghcr.io/<owner>/rocketride-engine:<tag> \
# --certificate-identity-regexp 'https://github\.com/<owner>/rocketride-server/.+' \
# --certificate-oidc-issuer https://token.actions.githubusercontent.com
- name: Install cosign
uses: sigstore/cosign-installer@7e8b541eb2e61bf99390e1afd4be13a184e9ebc5 # v3.10.1
- name: Sign image with cosign
env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/rocketride-engine
run: cosign sign --yes "${IMAGE}@${DIGEST}"
- name: Sign engine-base with cosign
env:
DIGEST: ${{ steps.base.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/rocketride-engine-base
run: cosign sign --yes "${IMAGE}@${DIGEST}"
# The image that runs one pipeline task. Never `latest`: a server starts
# tasks only from the node image of its own version, because the task
# protocol is not versioned.
- name: Build and push node image
id: node
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: docker/Dockerfile.node
build-args: |
ENGINE_BASE=ghcr.io/${{ github.repository_owner }}/rocketride-engine-base@${{ steps.base.outputs.digest }}
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository_owner }}/rocketride-node:${{ inputs.server_version }}${{ inputs.tag_suffix != '' && format('-{0}', inputs.tag_suffix) || (inputs.prerelease && '-prerelease' || '') }}
labels: |
org.opencontainers.image.revision=${{ steps.revision.outputs.sha }}
# Before signing, as for the engine image: a node image whose engine is
# dumpable, whose shipped constraints a container rejects, or whose cache
# cannot install a node offline should not acquire a signature.
- name: Check the node image
env:
DIGEST: ${{ steps.node.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/rocketride-node
run: |
set -euo pipefail
docker pull "${IMAGE}@${DIGEST}"
sh docker/test-node-image.sh "${IMAGE}@${DIGEST}"
- name: Sign node image with cosign
env:
DIGEST: ${{ steps.node.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/rocketride-node
run: cosign sign --yes "${IMAGE}@${DIGEST}"