Skip to content

Split docker image into multiple variants #457

Split docker image into multiple variants

Split docker image into multiple variants #457

Workflow file for this run

name: CI
on:
push:
tags:
- v*
branches:
- master
pull_request:
jobs:
build-libbpf-docker-x86_64:
name: Build libbpf in Docker (x86_64)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch with tags to have the build version attached
- name: Build libbpf
run: |
docker buildx build --progress plain --tag libbpf:builder --target libbpf_builder .
id=$(docker create libbpf:builder)
docker cp $id:/build/libbpf.tar.gz libbpf.x86_64.tar.gz
- name: Upload libbpf.tar.gz
uses: actions/upload-artifact@v3
with:
name: libbpf.x86_64.tar.gz
path: libbpf.x86_64.tar.gz
build-libbpf-docker-aarch64:
name: Build libbpf in Docker (aarch64, emulated)
runs-on: ubuntu-22.04
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch with tags to have the build version attached
- name: Build libbpf
run: |
docker buildx build --progress plain --tag libbpf:builder --target libbpf_builder --platform linux/arm64 .
id=$(docker create libbpf:builder)
docker cp $id:/build/libbpf.tar.gz libbpf.aarch64.tar.gz
- name: Upload libbpf.tar.gz
uses: actions/upload-artifact@v3
with:
name: libbpf.aarch64.tar.gz
path: libbpf.aarch64.tar.gz
build-ebpf-exporter-docker-x86_64:
name: Build ebpf_exporter in Docker (x86_64)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch with tags to have the build version attached
- name: Build libbpf and ebpf_exporter
run: |
docker buildx build --progress plain --tag ebpf_exporter:builder --target ebpf_exporter_builder .
id=$(docker create ebpf_exporter:builder)
docker cp $id:/build/ebpf_exporter/ebpf_exporter ebpf_exporter.x86_64
- name: Upload ebpf_exporter
uses: actions/upload-artifact@v3
with:
name: ebpf_exporter.x86_64
path: ebpf_exporter.x86_64
build-ebpf-exporter-docker-aarch64:
name: Build ebpf_exporter in Docker (aarch64, emulated)
runs-on: ubuntu-22.04
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch with tags to have the build version attached
- name: Build ebpf_exporter
run: |
docker buildx build --progress plain --tag ebpf_exporter:builder --target ebpf_exporter_builder --platform linux/arm64 .
id=$(docker create ebpf_exporter:builder)
docker cp $id:/build/ebpf_exporter/ebpf_exporter ebpf_exporter.aarch64
- name: Upload ebpf_exporter
uses: actions/upload-artifact@v3
with:
name: ebpf_exporter.aarch64
path: ebpf_exporter.aarch64
build-ebpf-exporter-static-x86_64:
name: Build ebpf_exporter (x86_64, statically linked)
needs: build-libbpf-docker-x86_64
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-go@v3
with:
go-version: ^1.21
- uses: actions/checkout@v3
- name: Download libbpf.tar.gz
uses: actions/download-artifact@v3
with:
name: libbpf.x86_64.tar.gz
- name: Install libbpf
run: sudo tar -C / -xvvf libbpf.x86_64.tar.gz
- name: Install libelf-dev
run: sudo apt-get install -y libelf-dev
- name: Build
run: make build
- name: Check static linkage
run: (ldd --verbose ./ebpf_exporter 2>&1 || true) | grep 'not a dynamic executable'
- name: Check that it runs
run: ./ebpf_exporter --version
build-ebpf-exporter-dynamic-x86_64:
name: Build ebpf_exporter (x86_64, dynamically linked)
needs: build-libbpf-docker-x86_64
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-go@v3
with:
go-version: ^1.21
- uses: actions/checkout@v3
- name: Download libbpf.tar.gz
uses: actions/download-artifact@v3
with:
name: libbpf.x86_64.tar.gz
- name: Install libbpf
run: sudo tar -C / -xvvf libbpf.x86_64.tar.gz
- name: Install libelf-dev
run: sudo apt-get install -y libelf-dev
- name: Build
run: make build-dynamic
- name: Check dynamic linkage
run: ldd --verbose ./ebpf_exporter
- name: Check that it runs
run: ./ebpf_exporter --version
test-ebpf-exporter-x86_64:
name: Test ebpf_exporter (x86_64)
needs: build-libbpf-docker-x86_64
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-go@v3
with:
go-version: ^1.21
- uses: actions/checkout@v3
- name: Download libbpf.tar.gz
uses: actions/download-artifact@v3
with:
name: libbpf.x86_64.tar.gz
- name: Install libbpf
run: sudo tar -C / -xvvf libbpf.x86_64.tar.gz
- name: Install libelf-dev
run: sudo apt-get install -y libelf-dev
- name: Update pci.ids
run: |
curl -o /tmp/pci.ids https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
sudo mv /tmp/pci.ids /usr/share/misc/pci.ids
- name: Test
run: make test
- name: Test privileged
run: make test-privileged
lint-ebpf-exporter-x86_64:
name: Lint ebpf_exporter (x86_64)
needs: build-libbpf-docker-x86_64
runs-on: ubuntu-22.04
steps:
- uses: actions/setup-go@v3
with:
go-version: ^1.21
- uses: actions/checkout@v3
- name: Download libbpf.tar.gz
uses: actions/download-artifact@v3
with:
name: libbpf.x86_64.tar.gz
- name: Install libbpf
run: sudo tar -C / -xvvf libbpf.x86_64.tar.gz
- name: Install libelf-dev
run: sudo apt-get install -y libelf-dev
- name: Check vendored dependencies
run: go mod verify
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
env:
CGO_LDFLAGS: "-l bpf"
build-examples-x86_64:
name: Build examples (x86_64)
needs: build-libbpf-docker-x86_64
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Download libbpf.tar.gz
uses: actions/download-artifact@v3
with:
name: libbpf.x86_64.tar.gz
- name: Install libbpf
run: sudo tar -C / -xvvf libbpf.x86_64.tar.gz
- name: Install libelf-dev
run: sudo apt-get install -y libelf-dev
- name: Install clang
run: sudo apt-get install -y clang
- name: Build benchmark bpf probes
run: make -j $(nproc) -C benchmark build
- name: Build example bpf probes
run: make -j $(nproc) -C examples build
clang-format:
name: Run clang-format check
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install clang-format
run: sudo apt-get install -y clang-format make
- name: Run clang-format check
run: make clang-format-check