Skip to content

Commit

Permalink
Multi arch builds (#15)
Browse files Browse the repository at this point in the history
1. Add intel/arm container builds
2. Do not pre-load module on build so that arm modules don't fail intel builds and vice versa
  • Loading branch information
corest authored Feb 15, 2024
1 parent 2782afe commit 6b7d115
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ci-modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ name: Build and Push PF_RING modules

on:
workflow_dispatch:
inputs:
tag:
type: choice
description: "Tag to build"
options:
- all
- canary
per-module:
type: boolean
description: "Build container per module"
default: true

jobs:
prepare-matrix:
if: inputs.per-module == 'true'
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.set-matrix.outputs.versions }}
Expand Down Expand Up @@ -60,6 +72,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -76,7 +91,7 @@ jobs:
images: kubeshark/pf-ring-module
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=all
type=raw,value=${{ inputs.tag}}
- name: Build and push
uses: docker/build-push-action@v5
Expand All @@ -85,6 +100,7 @@ jobs:
file: ./modules/Dockerfile.all
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64/v8

upload-modules-to-s3:
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions modules/Dockerfile.all
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Build container with all available modules
FROM alpine:3.18

COPY ko/*.ko /tmp/modules/
COPY scripts/load-all-modules.sh /opt/scripts/load-all-modules.sh
COPY ko/*.ko /opt/modules/
COPY scripts/entrypoint.sh /opt/scripts/entrypoint.sh

RUN /opt/scripts/load-all-modules.sh
RUN apk add kmod
ENTRYPOINT [ "/opt/scripts/entrypoint.sh" ]
3 changes: 1 addition & 2 deletions modules/Dockerfile.single
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
FROM alpine:3.18
ARG KERNEL_VERSION

COPY ko/pf-ring-${KERNEL_VERSION}.ko /opt/lib/modules/${KERNEL_VERSION}/pf_ring.ko
COPY ko/pf-ring-${KERNEL_VERSION}.ko /opt/modules/pf-ring-${KERNEL_VERSION}.ko
COPY scripts/entrypoint.sh /opt/scripts/entrypoint.sh
RUN apk add kmod

RUN depmod -b /opt ${KERNEL_VERSION}
ENTRYPOINT [ "/opt/scripts/entrypoint.sh" ]
Binary file not shown.
19 changes: 12 additions & 7 deletions modules/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
#!/bin/sh

# Get the current kernel version
current_kernel_version=$(uname -r)
kernel_version=$(uname -r)

# Check if the module directory exists for the current kernel
module_path="/opt/lib/modules/${current_kernel_version}/pf_ring.ko"
module_path="/opt/modules/pf-ring-${kernel_version}.ko"

if [ -f "$module_path" ]; then
# Check if the module is already loaded
if ! lsmod | grep -q pf_ring; then
echo "Loading pf_ring module for kernel ${current_kernel_version}"
insmod $module_path
echo "Loading pf_ring module for kernel ${kernel_version}"
module_load_path="/opt/lib/modules/${kernel_version}/pf_ring.ko"
mkdir /opt/lib/modules/${kernel_version} -p
cp $module_path ${module_load_path}
depmod -b /opt ${kernel_version}
insmod ${module_load_path}
if [ $? -ne 0 ]; then
echo "Failed to load module from $module_path"
echo "Failed to load module from ${module_load_path}"
echo "Falling back to AF_PACKET"
exit 0
fi
echo "pf_ring module loaded for kernel ${kernel_version}"
else
echo "pf_ring module is already loaded for kernel ${current_kernel_version}"
echo "pf_ring module is already loaded for kernel ${kernel_version}"
exit 0
fi
else
echo "No pf_ring module found for the current kernel version ${current_kernel_version}"
echo "No pf_ring module found for the current kernel version ${kernel_version}"
echo "Falling back to AF_PACKET"
fi
11 changes: 0 additions & 11 deletions modules/scripts/load-all-modules.sh

This file was deleted.

0 comments on commit 6b7d115

Please sign in to comment.