-
Notifications
You must be signed in to change notification settings - Fork 18
422 lines (407 loc) · 15.6 KB
/
docker.yml
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
name: Docker
on:
pull_request:
release:
types: [published]
push:
branches:
- develop
- main
- release\/*
jobs:
cancel_running_workflows:
name: Cancel running workflows
runs-on: ubuntu-22.04
steps:
- name: cancel running workflows
uses: RDXWorks-actions/cancel-workflow-action@main
with:
access_token: ${{ github.token }}
build_deb:
name: Build debian package
runs-on: selfhosted-ubuntu-22.04-16-cores
needs:
- setup_version_properties
outputs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
env:
VERSION_BRANCH: ${{ needs.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_COMMIT: ${{ needs.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY: ${{ needs.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_BUILD: ${{ needs.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_TAG: ${{ needs.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG: ${{ needs.setup_version_properties.outputs.VERSION_LAST_TAG }}
permissions:
id-token: write
contents: read
pull-requests: read
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: RDXWorks-actions/metadata-action@master
with:
images: |
docker.io/radixdlt/babylon-node
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor: |
latest=false
- uses: RDXWorks-actions/toolchain@master
with:
toolchain: stable
- name: Set up JDK 17
uses: RDXWorks-actions/setup-java@main
with:
distribution: 'zulu'
java-version: '17'
- name: Cache Gradle packages
uses: RDXWorks-actions/cache@main
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-deb
restore-keys: ${{ runner.os }}-gradle-deb
- name: Restore cached image-cache
id: cache-image-restore
uses: RDXWorks-actions/cache/restore@main
with:
path: /tmp/outputs/cache/docker
key: babylon-node-default-${{ hashFiles('./Dockerfile') }}
- name: Set up Docker Context for Buildx
run: |
docker context create builders | true
- name: Set up Docker Buildx
uses: RDXWorks-actions/setup-buildx-action@master
with:
version: latest
endpoint: builders
- name: Create deb package
run: |
sudo apt-get update && sudo apt-get install -y make
cd core && make build-core
- name: Upload generated debian package
uses: RDXWorks-actions/upload-artifact@main
with:
name: deb4docker
path: "${{ github.workspace }}/docker/*.deb"
setup_tags:
name: Setup Docker tags
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.setup_tags.outputs.tag }}
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- id: setup_tags
run: echo "tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
setup_version_properties:
name: Setup version properties
runs-on: ubuntu-latest
outputs:
VERSION_BRANCH: ${{ steps.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_BUILD: ${{ steps.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_COMMIT: ${{ steps.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY: ${{ steps.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_TAG: ${{ steps.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG: ${{ steps.setup_version_properties.outputs.VERSION_LAST_TAG }}
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Setup version properties
id: setup_version_properties
uses: ./.github/actions/setup-version-properties
build_push_container_private:
name: (PRIVATE) Docker AMD
needs:
- setup_tags
- setup_version_properties
permissions:
id-token: write
contents: read
pull-requests: write
packages: write
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: ubuntu-latest
image_registry: "docker.io"
image_organization: "radixdlt"
image_name: "private-babylon-node"
tag: ${{ needs.setup_tags.outputs.tag }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor:
${{ contains( github.event.pull_request.labels.*.name, 'ARM-TEST') && 'suffix=-amd64' || '' }}
${{ github.event_name != 'pull_request' && 'suffix=-amd64' || '' }}
context: "."
dockerfile: "./Dockerfile"
platforms: "linux/amd64"
cache_tag_suffix: "amd64"
use_gh_remote_cache: true
provenance: "false"
scan_image: true
snyk_target_ref: ${{ github.ref_name }}
build-args: |
VERSION_BRANCH=${{ needs.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_COMMIT=${{ needs.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY=${{ needs.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_BUILD=${{ needs.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_TAG=${{ needs.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG=${{ needs.setup_version_properties.outputs.VERSION_LAST_TAG }}
build_push_container_private_arm:
if: contains( github.event.pull_request.labels.*.name, 'ARM-TEST') || github.event_name != 'pull_request'
name: (PRIVATE) Docker ARM
needs:
- setup_tags
- setup_version_properties
permissions:
id-token: write
contents: read
pull-requests: write
packages: write
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: selfhosted-ubuntu-22.04-arm
image_registry: "docker.io"
image_organization: "radixdlt"
image_name: "private-babylon-node"
tag: ${{ needs.setup_tags.outputs.tag }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor: |
suffix=-arm64
context: "."
dockerfile: "./Dockerfile"
use_gh_remote_cache: true
provenance: "false"
scan_image: false
snyk_target_ref: ${{ github.ref_name }}
platforms: "linux/arm64"
cache_tag_suffix: arm64
build-args: |
WGET_VERSION=1.21.3-1+b1
VERSION_BRANCH=${{ needs.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_COMMIT=${{ needs.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY=${{ needs.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_BUILD=${{ needs.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_TAG=${{ needs.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG=${{ needs.setup_version_properties.outputs.VERSION_LAST_TAG }}
join_multiarch_image_private_dockerhub:
if: contains( github.event.pull_request.labels.*.name, 'ARM-TEST') || github.event_name != 'pull_request'
name: Join Multiarch Image Private Dockerhub
needs:
- build_push_container_private
- build_push_container_private_arm
permissions:
id-token: write
contents: read
pull-requests: read
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/join-docker-images-all-tags.yml@main
with:
aws_dockerhub_secret: github-actions/common/dockerhub-credentials
amd_meta_data_json: ${{needs.build_push_container_private.outputs.json}}
secrets:
role-to-assume: "arn:aws:iam::308190735829:role/gh-common-secrets-read-access"
build_push_container_dockerhub:
if: github.event_name == 'release'
name: (DockerHub) Docker AMD
needs:
- setup_version_properties
permissions:
id-token: write
contents: read
pull-requests: write
packages: write
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: ubuntu-latest
image_registry: "docker.io"
image_organization: "radixdlt"
image_name: "babylon-node"
tag: ${{ github.event.release.tag_name }}
flavor: |
suffix=-amd64
context: "."
dockerfile: "./Dockerfile"
platforms: "linux/amd64"
cache_tag_suffix: "amd64"
use_gh_remote_cache: true
enable_dockerhub: "true"
provenance: "false"
build-args: |
VERSION_BRANCH=${{ needs.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_COMMIT=${{ needs.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY=${{ needs.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_BUILD=${{ needs.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_TAG=${{ needs.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG=${{ needs.setup_version_properties.outputs.VERSION_LAST_TAG }}
secrets:
role_to_assume: ${{ secrets.DOCKERHUB_RELEASER_ROLE }}
build_push_container_dockerhub_arm:
if: github.event_name == 'release'
name: (DockerHub) Docker ARM
needs:
- setup_version_properties
permissions:
id-token: write
contents: read
pull-requests: write
packages: write
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: selfhosted-ubuntu-22.04-arm
image_registry: "docker.io"
image_organization: "radixdlt"
image_name: "babylon-node"
tag: ${{ github.event.release.tag_name }}
flavor: |
suffix=-arm64
context: "."
dockerfile: "./Dockerfile"
platforms: "linux/arm64"
cache_tag_suffix: "arm64"
use_gh_remote_cache: true
enable_dockerhub: "true"
provenance: "false"
build-args: |
WGET_VERSION=1.21.3-1+b1
VERSION_BRANCH=${{ needs.setup_version_properties.outputs.VERSION_BRANCH }}
VERSION_COMMIT=${{ needs.setup_version_properties.outputs.VERSION_COMMIT }}
VERSION_DISPLAY=${{ needs.setup_version_properties.outputs.VERSION_DISPLAY }}
VERSION_BUILD=${{ needs.setup_version_properties.outputs.VERSION_BUILD }}
VERSION_TAG=${{ needs.setup_version_properties.outputs.VERSION_TAG }}
VERSION_LAST_TAG=${{ needs.setup_version_properties.outputs.VERSION_LAST_TAG }}
secrets:
role_to_assume: ${{ secrets.DOCKERHUB_RELEASER_ROLE }}
join_multiarch_image_dockerhub:
if: contains( github.event.pull_request.labels.*.name, 'ARM-TEST') || github.event_name != 'pull_request'
name: Join Multiarch Image Private Dockerhub
needs:
- build_push_container_dockerhub
- build_push_container_dockerhub_arm
permissions:
id-token: write
contents: read
pull-requests: read
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/join-docker-images-all-tags.yml@main
with:
aws_dockerhub_secret: github-actions/rdxworks/dockerhub-images/release-credentials
amd_meta_data_json: ${{needs.build_push_container_dockerhub.outputs.json}}
secrets:
role-to-assume: ${{ secrets.DOCKERHUB_RELEASER_ROLE }}
snyk_container_monitor:
name: Snyk monitor container
runs-on: ubuntu-latest
needs:
- build_push_container_dockerhub
- build_push_container_dockerhub_arm
permissions:
id-token: write
pull-requests: read
contents: read
deployments: write
steps:
- uses: radixdlt/public-iac-resuable-artifacts/snyk-container-monitor@main
with:
role_name: ${{ secrets.AWS_ROLE_NAME_SNYK_SECRET }}
app_name: 'babylon-node'
dockerhub_secret_name: ${{ secrets.AWS_SECRET_NAME_DOCKERHUB }}
snyk_secret_name: ${{ secrets.AWS_SECRET_NAME_SNYK }}
snyk_org_id: ${{ secrets.SNYK_ORG_ID }}
image: docker.io/radixdlt/babylon-node:${{ github.event.release.tag_name }}-amd64
target_ref: ${{ github.ref_name }}
snyk_monitor:
name: Snyk monitor
runs-on: ubuntu-latest
needs:
- build_push_container_dockerhub
permissions:
id-token: write
pull-requests: read
contents: read
deployments: write
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: ${{ secrets.AWS_ROLE_NAME_SNYK_SECRET }}
app_name: 'babylon-node'
step_name: 'snyk-monitor'
secret_prefix: 'SNYK'
secret_name: ${{ secrets.AWS_SECRET_NAME_SNYK }}
parse_json: true
- name: Enable Snyk online monitoring to check for vulnerabilities
uses: RDXWorks-actions/snyk-actions/gradle-jdk17@master
with:
args: --all-projects --org=${{ env.SNYK_NETWORK_ORG_ID }} --target-reference=${{ github.ref_name }}
command: monitor
ephemeral-deploy-and-benchmark:
permissions:
id-token: write
contents: read
name: Deploy ephemeral environment and run benchmark tests.
needs:
- build_push_container_private
runs-on: ubuntu-22.04
steps:
- uses: RDXWorks-actions/checkout@main
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- uses: ./.github/actions/fetch-secrets
with:
role_name: "${{ secrets.BABYLON_SECRETS_ROLE_ARN }}"
app_name: "babylon-node"
step_name: "deploy"
secret_prefix: "JENKINS"
secret_name: "github-actions/radixdlt/babylon-node/jenkins-api-token"
parse_json: true
- name: Connect to tailnet
uses: radixdlt/public-iac-resuable-artifacts/tailnet@main
with:
role_name: "arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access"
region: "eu-west-2"
secret_name: "arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/tailscale-public-workflows-DpiE80"
- name: Get docker image tag
run: |
#There can be multiple tag entries. Get the first and only take the tag (i.e. not the image repo and name)
TAGS="${{ needs.build_deb.outputs.tags }}"
DOCKER_TAG=$(echo $TAGS | awk 'NR==1{print $1}' | cut -d':' -f2)
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
echo "GITHUB_REF_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> $GITHUB_ENV
- name: Deploy and test on ephemeral network
uses: RDXWorks-actions/jenkins-job-trigger-action@master
with:
jenkins_url: "${{ env.JENKINS_URL }}"
jenkins_user: ${{ env.JENKINS_USER }}
jenkins_token: ${{ env.JENKINS_TOKEN }}
job_name: "babylon-testing/job/ephemeral-deployments/job/ephemeral-node-ci-benchmark"
job_params: |
{
"RADIXDLT_NODE_DOCKER_TAG": "${{ env.DOCKER_TAG }}",
"RADIXDLT_GITHUB_TRIGGER" : "${{ env.GITHUB_REPOSITORY }}:${{ env.GITHUB_REF_NAME }}"
}
job_timeout: "3600"