Skip to content

Commit 4383287

Browse files
authored
chore: fix multi arch packages deploy (#742)
1 parent f0eb304 commit 4383287

File tree

13 files changed

+213
-92
lines changed

13 files changed

+213
-92
lines changed

.github/actions/build-cpp/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM debian:bookworm-slim
1+
FROM ubuntu:noble
22

3-
ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3 python3-pip python3-setuptools ca-certificates libasan6 zip curl wget"
3+
ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3 python3-pip python3-setuptools ca-certificates zip curl wget gcc-aarch64-linux-gnu g++-aarch64-linux-gnu"
44

55
COPY ./entrypoint.sh /entrypoint.sh
66

.github/actions/build-cpp/action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ inputs:
3333
required: true
3434
default: "ON"
3535

36+
arch:
37+
description: "arch"
38+
required: true
39+
default: "amd64"
40+
3641
file:
3742
description: "Dockerfile used to build the image"
3843
required: true

.github/actions/build-cpp/entrypoint.sh

+29-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,40 @@ function build() {
1313
cp -rf /github/workspace/3rd/ /pktvisor-src/3rd/
1414
cp -rf /github/workspace/libs/ /pktvisor-src/libs/
1515
cp -rf /github/workspace/docker/ /pktvisor-src/docker/
16-
cp -rf /github/workspace/golang/ /pktvisor-src/golang/
1716
cp -rf /github/workspace/build/ /pktvisor-src/build/
17+
cp -rf /github/workspace/golang/ /pktvisor-src/golang/
1818
cp -rf /github/workspace/integration_tests/ /pktvisor-src/integration_tests/
1919
cp -rf /github/workspace/cmake/ /pktvisor-src/cmake/
2020
cp -rf /github/workspace/CMakeLists.txt /pktvisor-src/
2121
cp -rf /github/workspace/conanfile.py /pktvisor-src/
22-
cd /pktvisor-src/build/
22+
cp -rf /github/workspace/.conanrc /pktvisor-src/
23+
cd /pktvisor-src/
2324
conan profile detect -f
24-
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake -DASAN=$INPUT_ASAN ..
25-
make all -j 4
25+
cd /pktvisor-src/build/
26+
if [ "$INPUT_ARCH" == "amd64" ]; then
27+
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake .. -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE \
28+
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake -DASAN=$INPUT_ASAN
29+
elif [ "$INPUT_ARCH" == "arm64" ]; then
30+
echo "[settings]
31+
os=Linux
32+
arch=armv8
33+
compiler=gcc
34+
compiler.version=13
35+
compiler.cppstd=17
36+
compiler.libcxx=libstdc++11
37+
build_type=$INPUT_BUILD_TYPE
38+
[buildenv]
39+
CC=/usr/bin/aarch64-linux-gnu-gcc
40+
CXX=/usr/bin/aarch64-linux-gnu-g++
41+
" | tee "$(conan config home)/profiles/host"
42+
conan install .. --profile host --build missing
43+
source $INPUT_BUILD_TYPE/generators/conanbuild.sh
44+
PKG_CONFIG_PATH=/local/lib/pkgconfig cmake .. -DCMAKE_BUILD_TYPE=$INPUT_BUILD_TYPE \
45+
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake -DASAN=$INPUT_ASAN \
46+
-DCONAN_HOST_PROFILE="host" -DCORRADE_RC_PROGRAM=$(command -v corrade-rc) \
47+
-DCONAN_INSTALL_ARGS=--build=never
48+
fi
49+
cmake --build . --config $INPUT_BUILD_TYPE -- -j 4
2650
}
2751

2852
function move() {
@@ -49,7 +73,7 @@ function publishToBugsplat() {
4973
./dump_syms /github/workspace/pktvisord > pktvisor.sym
5074
PKTVISOR_VERSION=$(cat VERSION)
5175
ls -lha
52-
./symupload -k $INPUT_BUGSPLAT_KEY pktvisor.sym $INPUT_BUGSPLAT_SYMBOL_URL$PKTVISOR_VERSION 2>/dev/null
76+
./symupload -k $INPUT_BUGSPLAT_KEY pktvisor.sym $INPUT_BUGSPLAT_SYMBOL_URL$INPUT_ARCH$PKTVISOR_VERSION 2>/dev/null
5377
fi
5478
}
5579

.github/workflows/build-develop.yml

+106-41
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
CTEST_OUTPUT_ON_FAILURE: 1
1717
CONAN_NON_INTERACTIVE: 1
1818
CONAN_REVISIONS_ENABLED: 1
19+
IMAGE_NAME: netboxlabs/pktvisor
1920

2021
jobs:
2122
unit-tests-mac:
@@ -61,7 +62,7 @@ jobs:
6162
- name: Test
6263
working-directory: ${{github.workspace}}/build
6364
shell: bash
64-
run: ctest -C $BUILD_TYPE
65+
run: ctest -C $BUILD_TYPE --output-on-failure
6566

6667
unit-tests-linux:
6768
runs-on: ubuntu-latest
@@ -82,8 +83,8 @@ jobs:
8283
uses: actions/cache@v4
8384
with:
8485
path: ${{github.workspace}}/build/p/
85-
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
86-
restore-keys: conan-${{ runner.os }}-
86+
key: conan-${{ runner.os }}-amd64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
87+
restore-keys: conan-${{ runner.os }}-amd64-
8788

8889
- name: Configure CMake
8990
shell: bash
@@ -104,7 +105,7 @@ jobs:
104105
- name: Test
105106
working-directory: ${{github.workspace}}/build
106107
shell: bash
107-
run: sudo ctest -C $BUILD_TYPE
108+
run: sudo ctest --output-on-failure
108109

109110
build-win64:
110111
runs-on: windows-2019
@@ -231,19 +232,20 @@ jobs:
231232
uses: actions/cache@v4
232233
with:
233234
path: ${{github.workspace}}/build/p/
234-
key: conan-${{ runner.os }}-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
235-
restore-keys: conan-${{ runner.os }}-
235+
key: conan-${{ runner.os }}-amd64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
236+
restore-keys: conan-${{ runner.os }}-amd64-
236237

237-
- name: Build pktvisord + push symbol to bugsplat.com
238+
- name: Build pktvisord + push symbol to backtrace.io
238239
uses: ./.github/actions/build-cpp
239240
with:
240241
context: "."
241242
build_type: "Release"
242243
asan: "OFF"
243244
bugsplat_key: ${{secrets.BUGSPLAT_KEY}}
244245
bugsplat_symbol_url: ${{secrets.BUGSPLAT_SYMBOL_URL}}
245-
bugsplat: "true"
246+
bugsplat: "false"
246247
file: "./Dockerfile"
248+
arch: "amd64"
247249

248250
- name: Build pktvisor-cli
249251
uses: ./.github/actions/build-go
@@ -255,15 +257,14 @@ jobs:
255257
run: ls -lha .
256258

257259
- name: Get VERSION
258-
id: build
259260
run: |
260261
echo "VERSION=${{needs.unit-tests-linux.outputs.version_number}}" >> $GITHUB_ENV
261262
262-
- name: Generate ref tag (develop)
263-
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV
264-
265-
- name: Debug ref tag
266-
run: echo ${{ env.REF_TAG }}
263+
- name: Docker meta
264+
id: meta
265+
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 #v5.6.1
266+
with:
267+
images: ${{ env.IMAGE_NAME }}
267268

268269
- name: Login to Docker Hub
269270
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
@@ -289,24 +290,33 @@ jobs:
289290
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 #v3.8.0
290291

291292
- name: Build + push - pktvisor (multi-arch)
292-
env:
293-
IMAGE_NAME: netboxlabs/pktvisor
294293
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0
294+
id: docker_build
295295
with:
296296
builder: ${{ steps.buildx.outputs.name }}
297297
context: .
298298
file: ./docker/Dockerfile.crashhandler
299299
platforms: linux/amd64
300-
push: true
301-
tags: |
302-
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
303-
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
304-
outputs: type=docker,dest=/tmp/amd64.tar
300+
labels: ${{ steps.meta.outputs.labels }}
301+
outputs: type=image,"name=${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
302+
303+
- name: Export digest
304+
run: |
305+
mkdir -p /tmp/digests
306+
digest="${{ steps.docker_build.outputs.digest }}"
307+
touch "/tmp/digests/${digest#sha256:}"
308+
309+
- name: Upload digest
310+
uses: actions/upload-artifact@v4
311+
with:
312+
name: digests-linux-amd64
313+
path: /tmp/digests/*
314+
if-no-files-found: error
315+
retention-days: 1
305316

306317
build-app-image-x64:
307-
needs: [ package-amd64 ]
318+
needs: [ merge-packages ]
308319
runs-on: ubuntu-latest
309-
#if: github.event_name != 'pull_request'
310320
steps:
311321
- uses: actions/checkout@v4
312322

@@ -317,6 +327,13 @@ jobs:
317327
id: conan
318328
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d #v1.2
319329

330+
- name: Setup Conan Cache
331+
uses: actions/cache@v4
332+
with:
333+
path: ${{github.workspace}}/build/p/
334+
key: conan-${{ runner.os }}-amd64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
335+
restore-keys: conan-${{ runner.os }}-amd64-
336+
320337
- name: Configure CMake to generate VERSION
321338
shell: bash
322339
working-directory: ${{github.workspace}}/build
@@ -365,15 +382,13 @@ jobs:
365382

366383
- name: Build + push - pktvisor-prom-write
367384
env:
368-
IMAGE_NAME: netboxlabs/pktvisor-prom-write
385+
PROM_IMAGE_NAME: netboxlabs/pktvisor-prom-write
369386
working-directory: ${{github.workspace}}/centralized_collection/prometheus/docker-grafana-agent
370387
run: |
371-
docker build . --file Dockerfile --build-arg PKTVISOR_TAG=${{ env.REF_TAG }} --tag ${{ env.IMAGE_NAME }}:${{ env.VERSION }} --tag ${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
372-
docker push -a ${{ env.IMAGE_NAME }}
388+
docker build . --file Dockerfile --build-arg PKTVISOR_TAG=${{ env.REF_TAG }} --tag ${{ env.PROM_IMAGE_NAME }}:${{ env.VERSION }} --tag ${{ env.PROM_IMAGE_NAME }}:${{ env.REF_TAG }}
389+
docker push -a ${{ env.PROM_IMAGE_NAME }}
373390
374391
- name: Generate AppImage
375-
env:
376-
IMAGE_NAME: netboxlabs/pktvisor
377392
working-directory: ${{github.workspace}}/appimage
378393
run: |
379394
DEV_IMAGE="${{ env.IMAGE_NAME }}:${{ env.VERSION }}" DEV_MODE=t make pktvisor-x86_64.AppImage
@@ -406,8 +421,8 @@ jobs:
406421
path: ${{github.workspace}}/build/p/
407422
key: conan-${{ runner.os }}-arm64-${{ hashFiles('conanfile.py', '*/conanfile.py') }}
408423
restore-keys: conan-${{ runner.os }}-arm64-
409-
410-
- name: Build pktvisord + push symbol to bugsplat.com
424+
425+
- name: Build pktvisord + push symbol to backtrace.io
411426
uses: ./.github/actions/build-cpp
412427
with:
413428
context: "."
@@ -417,6 +432,7 @@ jobs:
417432
bugsplat_symbol_url: ${{secrets.BUGSPLAT_SYMBOL_URL}}
418433
bugsplat: "false"
419434
file: "./Dockerfile"
435+
arch: "arm64"
420436

421437
- name: Build pktvisor-cli
422438
uses: ./.github/actions/build-go
@@ -428,11 +444,11 @@ jobs:
428444
- name: Debug artifacts
429445
run: ls -lha .
430446

431-
- name: Generate ref tag (develop)
432-
run: echo "REF_TAG=latest-develop" >> $GITHUB_ENV
433-
434-
- name: Debug ref tag
435-
run: echo ${{ env.REF_TAG }}
447+
- name: Docker meta
448+
id: meta
449+
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 #v5.6.1
450+
with:
451+
images: ${{ env.IMAGE_NAME }}
436452

437453
- name: Login to Docker Hub
438454
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
@@ -459,16 +475,65 @@ jobs:
459475
460476
- name: Build + push - pktvisor (multi-arch)
461477
id: docker_build
462-
env:
463-
IMAGE_NAME: netboxlabs/pktvisor
464478
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0
465479
with:
466480
builder: ${{ steps.buildx.outputs.name }}
467481
context: .
468482
file: ./docker/Dockerfile.crashhandler
469483
platforms: linux/arm64
470-
push: true
484+
labels: ${{ steps.meta.outputs.labels }}
485+
outputs: type=image,"name=${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
486+
487+
- name: Export digest
488+
run: |
489+
mkdir -p /tmp/digests
490+
digest="${{ steps.docker_build.outputs.digest }}"
491+
touch "/tmp/digests/${digest#sha256:}"
492+
493+
- name: Upload digest
494+
uses: actions/upload-artifact@v4
495+
with:
496+
name: digests-linux-arm64
497+
path: /tmp/digests/*
498+
if-no-files-found: error
499+
retention-days: 1
500+
501+
merge-packages:
502+
runs-on: ubuntu-latest
503+
needs: [unit-tests-linux, package-amd64, package-arm64]
504+
steps:
505+
- name: Download digests
506+
uses: actions/download-artifact@v4
507+
with:
508+
path: /tmp/digests
509+
pattern: digests-*
510+
merge-multiple: true
511+
512+
- name: Login to Docker Hub
513+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
514+
with:
515+
username: ${{ secrets.DOCKERHUB_USERNAME }}
516+
password: ${{ secrets.DOCKERHUB_TOKEN }}
517+
518+
- name: Set up Docker Buildx
519+
id: buildx
520+
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 #v3.8.0
521+
522+
- name: Docker meta
523+
id: meta
524+
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 #v5.6.1
525+
with:
526+
images: ${{ env.IMAGE_NAME }}
471527
tags: |
472-
${{ env.IMAGE_NAME }}:${{ needs.unit-tests-linux.outputs.version_number }}
473-
${{ env.IMAGE_NAME }}:${{ env.REF_TAG }}
474-
outputs: type=docker,dest=/tmp/arm64.tar
528+
type=raw,value=latest-develop
529+
type=raw,value=${{ needs.unit-tests-linux.outputs.version_number }}
530+
531+
- name: Create manifest list and push
532+
working-directory: /tmp/digests
533+
run: |
534+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
535+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
536+
537+
- name: Inspect image
538+
run: |
539+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

.github/workflows/build-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Test
5353
working-directory: ${{github.workspace}}/build
5454
shell: bash
55-
run: sudo ctest -C $BUILD_TYPE
55+
run: sudo ctest --output-on-failure
5656

5757
prebuild-package:
5858
needs: [ unit-tests ]

.github/workflows/build_cross.yml

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ jobs:
114114
LDFLAGS=${{matrix.ldflags}}
115115
EOF
116116
117+
- name: Setup Conan Cache
118+
uses: actions/cache@v4
119+
with:
120+
path: ${{github.workspace}}/src/build/p/
121+
key: conan-${{ runner.os }}-${{matrix.arch}}-${{ hashFiles('**/conanfile.py') }}
122+
restore-keys: conan-${{ runner.os }}-${{matrix.arch}}-
123+
117124
- name: Install dependencies
118125
working-directory: ${{github.workspace}}/src
119126
run: |

0 commit comments

Comments
 (0)