forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
803 lines (726 loc) · 30.1 KB
/
image-build.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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
name: bpfman-image-build
on: # yamllint disable-line rule:truthy
push:
branches: [main]
tags:
- v*
pull_request:
paths:
- .github/workflows/image-build.yml
- Containerfile.bpfman.multi.arch
- Containerfile.bytecode.multi.arch
- examples/**/container-deployment/Containerfile**
workflow_dispatch:
jobs:
# Build bpfman and store the bpfman CLI binary in artifacts for the
# "build-and-push-bytecode-images" step. It will be used to generate
# build args with the "bpfman image generate-build-args" command.
build-bpfman-for-build-arg-gen:
runs-on: ubuntu-24.04
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Build bpfman binary
run: cargo build -p bpfman --verbose
- name: archive bpfman binary
run: |
cd target/debug
tar -czvf bpfman.tar.gz bpfman
- name: Archive bpfman Binaries
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # @v4
with:
name: bpfman-for-build-args
path: |
./target/debug/bpfman.tar.gz
# Build bpfman for each architecture and store the bpfman binaries in artifacts
# for the "build-and-push-userspace-images" step. The rust tool `cross` cannot be run in a
# container, so build the binaries locally, and the container build will just copy
# the files into the container.
build-bpfman-per-arch:
permissions:
contents: read
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
arch:
- arch: amd64
rust-target: x86_64-unknown-linux-gnu
filename: linux-x86_64
command: cargo
- arch: arm64
rust-target: aarch64-unknown-linux-gnu
filename: linux-arm64
command: cross
- arch: ppc64le
rust-target: powerpc64le-unknown-linux-gnu
filename: linux-ppc64le
command: cross
- arch: s390x
rust-target: s390x-unknown-linux-gnu
filename: linux-s390x
command: cross
name: Build bpfman (bpfman-${{ matrix.arch.arch }})
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Install rust toolchain - stable
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1
with:
toolchain: stable
override: true
target: ${{ matrix.arch.rust-target }}
# Only install cross if we need it
- name: Install Cross
if: ${{ matrix.arch.command == 'cross' }}
shell: bash
run: |
cargo install cross --git https://github.com/cross-rs/cross
# TODO: Is this needed? Quick glance this action is supposed to speed up rust builds
# with some caching, but not sure of the details. Need to run with it enabled
# and disabled and see if it speeds anything up or not.
# - uses: Swatinem/rust-cache@v2
- name: Build Binary
run: |
${{ matrix.arch.command }} build --release --target ${{ matrix.arch.rust-target }}
- name: Package bpfman Binaries
run: |
cd target/${{ matrix.arch.rust-target }}/release
tar -czvf bpfman-build-${{ matrix.arch.filename }}.tar.gz bpfman bpfman-rpc bpfman-ns bpf-metrics-exporter bpf-log-exporter
- name: Archive bpfman Binaries
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # @v4
with:
name: bpfman-build-${{ matrix.arch.filename }}
path: ./target/${{ matrix.arch.rust-target }}/release/bpfman-build-${{ matrix.arch.filename }}.tar.gz
# Build all the userspace images and push them to quay.io. This includes bpfman
# as well as the go-*-counter examples.
build-and-push-userspace-images:
needs: [build-bpfman-per-arch]
permissions:
contents: read
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
image:
- registry: quay.io
repository: bpfman
image: bpfman
dockerfile: ./Containerfile.bpfman.multi.arch
context: .
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-xdp-counter
context: .
dockerfile: ./examples/go-xdp-counter/container-deployment/Containerfile.go-xdp-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-tc-counter
context: .
dockerfile: ./examples/go-tc-counter/container-deployment/Containerfile.go-tc-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-tcx-counter
context: .
dockerfile: ./examples/go-tcx-counter/container-deployment/Containerfile.go-tcx-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
# build_language: go - Not building locally, so don't install go tools
repository: bpfman-userspace
image: go-tracepoint-counter
context: .
dockerfile: ./examples/go-tracepoint-counter/container-deployment/Containerfile.go-tracepoint-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-kprobe-counter
context: .
dockerfile: ./examples/go-kprobe-counter/container-deployment/Containerfile.go-kprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-uprobe-counter
context: .
dockerfile: ./examples/go-uprobe-counter/container-deployment/Containerfile.go-uprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-uretprobe-counter
context: .
dockerfile: ./examples/go-uretprobe-counter/container-deployment/Containerfile.go-uretprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-target
context: .
dockerfile: ./examples/go-target/container-deployment/Containerfile.go-target
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
repository: bpfman-userspace
image: go-app-counter
context: .
dockerfile: ./examples/go-app-counter/container-deployment/Containerfile.go-app-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
name: Build Image (${{ matrix.image.image }})
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Install cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # @v3.7.0
- name: Login to quay.io/bpfman
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # @v1
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && matrix.image.repository == 'bpfman'}}
with:
registry: ${{ matrix.image.registry }}
username: ${{ secrets.BPFMAN_USERNAME }}
password: ${{ secrets.BPFMAN_ROBOT_TOKEN }}
- name: Login to quay.io/bpfman-userspace
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # @v1
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && matrix.image.repository == 'bpfman-userspace'}}
with:
registry: ${{ matrix.image.registry }}
username: ${{ secrets.BPFMAN_USERSPACE_USERNAME }}
password: ${{ secrets.BPFMAN_USERSPACE_ROBOT_TOKEN }}
- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # @v5.6.1
with:
images: ${{ matrix.image.registry }}/${{ matrix.image.repository }}/${{ matrix.image.image }}
tags: ${{ matrix.image.tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # @v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # @v3
# bpfman ONLY
- name: Update .dockerignore to allow "target/" directory
if: ${{ matrix.image.image == 'bpfman'}}
run: |
sed -i '/target/d' ./.dockerignore
# bpfman ONLY
- name: Download built bpfman Binaries
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
if: ${{ matrix.image.image == 'bpfman'}}
with:
pattern: bpfman-build-*
merge-multiple: true
# bpfman ONLY
- name: Unpack built bpfman binaries
if: ${{ matrix.image.image == 'bpfman'}}
run: |
mkdir -p target/x86_64-unknown-linux-gnu/release
tar -C target/x86_64-unknown-linux-gnu/release -xzvf bpfman-build-linux-x86_64.tar.gz
mkdir -p target/aarch64-unknown-linux-gnu/release
tar -C target/aarch64-unknown-linux-gnu/release -xzvf bpfman-build-linux-arm64.tar.gz
mkdir -p target/powerpc64le-unknown-linux-gnu/release
tar -C target/powerpc64le-unknown-linux-gnu/release -xzvf bpfman-build-linux-ppc64le.tar.gz
mkdir -p target/s390x-unknown-linux-gnu/release
tar -C target/s390x-unknown-linux-gnu/release -xzvf bpfman-build-linux-s390x.tar.gz
- name: Build and push
id: build-push-image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # @v6
with:
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.image.dockerfile }}
build-args: ${{ matrix.image.build_args }}
context: ${{ matrix.image.context }}
- name: Sign the images with GitHub OIDC Token
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
run: |
readarray -t tags <<<"${{ steps.meta.outputs.tags }}"
for tag in ${tags[@]}; do
cosign sign -y "${tag}@${{ steps.build-push-image.outputs.digest }}"
done
# Build all the bytecode images and push them to quay.io. This includes the dispatchers
# for TC and XDP, all the go-*-counter examples and the bytecode images used by integration
# tests.
build-and-push-bytecode-images:
needs: [build-bpfman-for-build-arg-gen]
permissions:
contents: read
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
image:
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-xdp-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-xdp-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-tc-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-tc-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-tcx-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-tcx-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-tracepoint-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-tracepoint-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-kprobe-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-kprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-uprobe-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-uprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-uretprobe-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-uretprobe-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: go
bpf_build_wrapper: go
repository: bpfman-bytecode
image: go-app-counter
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./examples/go-app-counter
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: xdp_pass
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/xdp_pass.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: xdp_pass_private
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/xdp_pass.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: tc_pass
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/tc_pass.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: tcx_test
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/tcx_test.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: tracepoint
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/tp_openat.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: uprobe
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/uprobe.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: uretprobe
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/uprobe.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: kprobe
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/kprobe.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: kretprobe
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/kprobe.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: fentry
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/fentry.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman-bytecode
image: fexit
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./tests/integration-test/bpf/.output/fentry.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman
image: xdp-dispatcher
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./.output/xdp_dispatcher_v2.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
- registry: quay.io
build_language: rust
bpf_build_wrapper: rust
repository: bpfman
image: tc-dispatcher
context: .
dockerfile: ./Containerfile.bytecode.multi.arch
bytecode_dir: ./.output/tc_dispatcher.bpf
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
name: Build eBPF Image (${{ matrix.image.image }})
steps:
- name: Checkout bpfman
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
- name: Install Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # @v5
if: ${{ matrix.image.build_language == 'go' }}
with:
# prettier-ignore
go-version: '1.22' # yamllint disable-line rule:quoted-strings
- name: Install cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # @v3.7.0
- name: Checkout libbpf
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4
if: ${{ matrix.image.bpf_build_wrapper == 'rust' }}
with:
repository: libbpf/libbpf
path: libbpf
- name: Install rust toolchain - stable
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1
if: ${{ matrix.image.build_language == 'rust' }}
with:
toolchain: stable
override: true
- name: Install libelf-dev
if: ${{ matrix.image.bpf_build_wrapper == 'rust' || matrix.image.bpf_build_wrapper == 'go' }}
run: |
sudo apt-get update
sudo apt-get install -y linux-headers-`uname -r` clang lldb lld libelf-dev gcc-multilib libbpf-dev
- name: Build rust wrapped eBPF
if: ${{ matrix.image.bpf_build_wrapper == 'rust' }}
run: |
cargo xtask build-ebpf --libbpf-dir ./libbpf
- name: Generate go wrapped eBPF
if: ${{ matrix.image.bpf_build_wrapper == 'go' }}
run: |
cd examples && make generate
- name: Login to quay.io/bpfman
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # @v1
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && matrix.image.repository == 'bpfman'}}
with:
registry: ${{ matrix.image.registry }}
username: ${{ secrets.BPFMAN_USERNAME }}
password: ${{ secrets.BPFMAN_ROBOT_TOKEN }}
- name: Login to quay.io/bpfman-bytecode
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # @v1
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && matrix.image.repository == 'bpfman-bytecode' }}
with:
registry: ${{ matrix.image.registry }}
username: ${{ secrets.BPFMAN_BYTECODE_USERNAME }}
password: ${{ secrets.BPFMAN_BYTECODE_ROBOT_TOKEN }}
- name: Download bpfman binary
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4
with:
name: bpfman-for-build-args
- name: Unpack bpfman binary
run: |
tar -C /usr/local/bin -xzvf bpfman.tar.gz
- name: Extract metadata (tags, labels) for image
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # @v5.6.1
with:
images: ${{ matrix.image.registry }}/${{ matrix.image.repository }}/${{ matrix.image.image }}
tags: ${{ matrix.image.tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # @v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # @v3
- name: Manually generate build args
id: build-tags
run: |
bytecode_data=$(bpfman image generate-build-args --cilium-ebpf-project ${{ matrix.image.bytecode_dir }})
build_args="${bytecode_data}\n"
printf BUILD_ARGS="$build_args" >> $GITHUB_ENV
{
echo 'BUILD_ARGS<<EOF'
printf "$build_args"
echo EOF
} >> "$GITHUB_ENV"
- name: Build and push
id: build-push-image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # @v6
with:
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.image.dockerfile }}
build-args: ${{ env.BUILD_ARGS }}
context: ${{ matrix.image.context }}
- name: Sign the images with GitHub OIDC Token
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
run: |
readarray -t tags <<<"${{ steps.meta.outputs.tags }}"
for tag in ${tags[@]}; do
cosign sign -y "${tag}@${{ steps.build-push-image.outputs.digest }}"
done