Skip to content

Commit 6626fdb

Browse files
authored
Fix kernel builds; Migrate ci runners (#291)
## Description The `debian:stable` container image, combined with the packages we install for building the kernel, doesn't include Make anymore, so we explicitly add it. Also, move to CNCF GitHub Action runners as the self-hosted runners in Equinix Metal are going away with the Equinix Metal sunset. ## Why is this needed Fixes: # ## How Has This Been Tested? ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
2 parents 82e48f8 + 762391a commit 6626fdb

File tree

5 files changed

+135
-29
lines changed

5 files changed

+135
-29
lines changed

.github/workflows/build-all-matrix.yaml

Lines changed: 91 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ env: # Global environment, passed to all jobs & all steps
2525
CI_TAGS: "standard armbian-sbc armbian-uefi lts" # 'dev' is not included
2626

2727
# GHA runner configuration. See bash/json-matrix.sh for more details.
28-
CI_RUNNER_LK_CONTAINERS_ARM64: "oracle-24cpu-384gb-arm64" # Use a self-hosted runner with the "ARM64" tag for the ARM64 builds of LK containers
29-
CI_RUNNER_LK_CONTAINERS_AMD64: "oracle-24cpu-384gb-x86-64" # Use a self-hosted runner with the "X86" tag for the AMD64 builds of LK containers
30-
CI_RUNNER_LK_ARM64: "oracle-24cpu-384gb-arm64" # Use a self-hosted runner with the "ARM64" tag for the ARM64 linuxkit builds
31-
CI_RUNNER_LK_AMD64: "oracle-24cpu-384gb-x86-64" # Use a self-hosted runner with the "X86" tag for the AMD64 linuxkit builds
28+
CI_RUNNER_LK_CONTAINERS_ARM64: "oracle-vm-32cpu-128gb-arm64" # Use a self-hosted runner with the "ARM64" tag for the ARM64 builds of LK containers
29+
CI_RUNNER_LK_CONTAINERS_AMD64: "oracle-vm-32cpu-128gb-x86-64" # Use a self-hosted runner with the "X86" tag for the AMD64 builds of LK containers
30+
CI_RUNNER_LK_ARM64: "oracle-vm-32cpu-128gb-arm64" # Use a self-hosted runner with the "ARM64" tag for the ARM64 linuxkit builds
31+
CI_RUNNER_LK_AMD64: "oracle-vm-32cpu-128gb-x86-64" # Use a self-hosted runner with the "X86" tag for the AMD64 linuxkit builds
3232
CI_RUNNER_KERNEL_AMD64: "oracle-24cpu-384gb-x86-64" # Use a self-hosted runner with the "X86" tag for the AMD64 kernel builds
3333
CI_RUNNER_KERNEL_ARM64: "oracle-24cpu-384gb-arm64" # Use a self-hosted runner with the "ARM64" tag for the ARM64 kernel builds
3434

@@ -45,7 +45,7 @@ jobs:
4545
lk_hooks_json: ${{ steps.prepare-matrix.outputs.lk_hooks_json }}
4646
steps:
4747
- name: Checkout repo
48-
uses: actions/checkout@v4
48+
uses: actions/checkout@v5
4949

5050
- name: Prepare release ID (current date) # This only used for the GitHub Release; not included in any way in the build process.
5151
id: date_prep
@@ -60,21 +60,27 @@ jobs:
6060

6161
build-linuxkit-containers:
6262
needs: [ matrix_prep ]
63-
runs-on: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
63+
runs-on:
64+
group: Default
65+
labels: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
6466
strategy:
6567
fail-fast: true
6668
matrix:
6769
include: ${{ fromJSON(needs.matrix_prep.outputs.lkcontainers_json) }}
6870
name: "LinuxKit containers for ${{ matrix.docker_arch }}"
6971
steps:
7072
- name: Checkout build repo
71-
uses: actions/checkout@v4
73+
uses: actions/checkout@v5
7274

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

7678
- name: Set up Docker Buildx
7779
uses: docker/setup-buildx-action@v3
80+
with:
81+
buildkitd-config-inline: |
82+
[registry."docker.io"]
83+
mirrors = ["mirror.gcr.io"]
7884
7985
- name: Docker Login to quay.io
8086
if: ${{ env.REGISTRY == 'quay.io' && github.ref == 'refs/heads/main' }}
@@ -86,26 +92,41 @@ jobs:
8692
uses: docker/login-action@v3
8793
with: { registry: "ghcr.io", username: "${{ github.repository_owner }}", password: "${{ secrets.GITHUB_TOKEN }}" }
8894

89-
- name: Build and Push LinuxKit containers for ${{matrix.docker_arch}}
95+
- name: Build and Push and Export LinuxKit containers for ${{matrix.docker_arch}}
9096
env:
9197
DOCKER_ARCH: "${{ matrix.docker_arch }}"
9298
DO_PUSH: "${{ github.ref == 'refs/heads/main' && 'yes' || 'no' }}"
99+
EXPORT_LK_CONTAINERS: "${{ github.event_name == 'pull_request' && 'yes' || 'no' }}" # Builds on PRs don't push images to a registry so they need to be passed on through GitHub Artifacts.
100+
EXPORT_LK_CONTAINERS_DIR: "${{ runner.temp }}"
93101
run: bash build.sh linuxkit-containers
94-
102+
103+
- name: Upload Linuxkit Docker images as GitHub Artifacts
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: linuxkit-images-${{ matrix.docker_arch }}
107+
path: ${{ runner.temp }}/*-${{ matrix.docker_arch }}.tar.gz
108+
retention-days: 1
109+
95110
build-kernels:
96111
needs: [ matrix_prep ] # depend on the previous job...
97-
runs-on: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
112+
runs-on:
113+
group: Default
114+
labels: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
98115
strategy:
99116
fail-fast: false # let other jobs try to complete if one fails, kernels might take long, and they'd be skipped on the next run
100117
matrix:
101118
include: ${{ fromJSON(needs.matrix_prep.outputs.kernels_json) }}
102119
name: "Kernel ${{ matrix.kernel }}"
103120
steps:
104121
- name: Checkout build repo
105-
uses: actions/checkout@v4
122+
uses: actions/checkout@v5
106123

107124
- name: Set up Docker Buildx # nb: no need for qemu here, kernels are cross-compiled, instead of the compilation being emulated
108125
uses: docker/setup-buildx-action@v3
126+
with:
127+
buildkitd-config-inline: |
128+
[registry."docker.io"]
129+
mirrors = ["mirror.gcr.io"]
109130
110131
- name: Docker Login to quay.io
111132
if: ${{ env.REGISTRY == 'quay.io' && github.ref == 'refs/heads/main' }}
@@ -117,25 +138,40 @@ jobs:
117138
uses: docker/login-action@v3
118139
with: { registry: "ghcr.io", username: "${{ github.repository_owner }}", password: "${{ secrets.GITHUB_TOKEN }}" }
119140

120-
- name: Build and push Kernel ${{matrix.kernel}} (${{ matrix.arch }})
141+
- name: Build and Push and Export Kernel ${{matrix.kernel}} (${{ matrix.arch }})
121142
env:
122143
DO_PUSH: "${{ github.ref == 'refs/heads/main' && 'yes' || 'no' }}"
144+
EXPORT_KERNEL_IMAGE: "${{ github.event_name == 'pull_request' && 'yes' || 'no' }}" # Builds on PRs don't push images to a registry so they need to be passed on through GitHub Artifacts.
145+
EXPORT_KERNEL_IMAGE_DIR: "${{ runner.temp }}"
123146
run: bash build.sh build-kernel "${{ matrix.kernel }}"
124147

148+
- name: Upload Kernel Docker images as GitHub Artifacts
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: kernel-images-${{ matrix.kernel }}
152+
path: ${{ runner.temp }}/hook-kernel-*.tar.gz
153+
retention-days: 1
154+
125155
build-hook-ensemble:
126156
needs: [ matrix_prep, build-linuxkit-containers, build-kernels ] # depend on the previous job...
127-
runs-on: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
157+
runs-on:
158+
group: Default
159+
labels: "${{ matrix.runner }}" # the runner to use is determined by the 'gha-matrix' code
128160
strategy:
129161
fail-fast: false # let other jobs try to complete if one fails
130162
matrix:
131163
include: ${{ fromJSON(needs.matrix_prep.outputs.lk_hooks_json) }}
132164
name: "Hook ${{ matrix.kernel }}"
133165
steps:
134166
- name: Checkout build repo
135-
uses: actions/checkout@v4
167+
uses: actions/checkout@v5
136168

137169
- name: Set up Docker Buildx # nb: no need for qemu here, kernels are cross-compiled, instead of the compilation being emulated
138170
uses: docker/setup-buildx-action@v3
171+
with:
172+
buildkitd-config-inline: |
173+
[registry."docker.io"]
174+
mirrors = ["mirror.gcr.io"]
139175
140176
- name: Docker Login to DockerHub # read-only token, required to be able to pull all the linuxkit pkgs without getting rate limited.
141177
if: ${{ env.LOGIN_TO_DOCKERHUB == 'yes' && github.ref == 'refs/heads/main' }}
@@ -163,6 +199,42 @@ jobs:
163199
lk-cache-${{ matrix.docker_arch }}
164200
save-always: true # always save the cache, even if build fails
165201

202+
- name: Download Linuxkit artifacts
203+
uses: actions/download-artifact@v5
204+
with:
205+
name: linuxkit-images-${{ matrix.docker_arch }}
206+
path: ${{ runner.temp }}
207+
208+
- name: Load Linuxkit Docker images into local Docker daemon
209+
run: |
210+
ls "${{ runner.temp }}"
211+
imgs=$(ls "${{ runner.temp }}" | grep tar.gz | xargs)
212+
echo "Found hook images: ${imgs}"
213+
for img in ${imgs}; do
214+
echo "extracting and loading image: ${{ runner.temp }}/${img}"
215+
gunzip -d "${{ runner.temp }}/${img}"
216+
docker load --input "${{ runner.temp }}/${img%.*}"
217+
done
218+
docker images
219+
220+
- name: Download Kernel artifacts
221+
uses: actions/download-artifact@v5
222+
with:
223+
name: kernel-images-${{ matrix.kernel }}
224+
path: ${{ runner.temp }}
225+
226+
- name: Load Kernel Docker images into local Docker daemon
227+
run: |
228+
ls "${{ runner.temp }}"
229+
imgs=$(ls "${{ runner.temp }}" | grep tar.gz | xargs)
230+
echo "Found kernel images: ${{ runner.temp }}/${imgs}"
231+
for img in ${imgs}; do
232+
echo "extracting and loading image: ${{ runner.temp }}/${img}"
233+
gunzip -d "${{ runner.temp }}/${img}"
234+
docker load --input "${{ runner.temp }}/${img%.*}"
235+
done
236+
docker images
237+
166238
- name: "Build Hook with Kernel ${{matrix.kernel}} (${{ matrix.arch }}) - cache: ${{matrix.gha_cache}}"
167239
env:
168240
DO_BUILD_LK_CONTAINERS: "no" # already built them; this is only for hook/linuxkit.
@@ -181,6 +253,7 @@ jobs:
181253
path: |
182254
out/*.tar.gz
183255
out/*.iso
256+
retention-days: 1
184257

185258
release-latest:
186259
name: Publish all Hooks to GitHub Releases
@@ -190,10 +263,10 @@ jobs:
190263
steps:
191264

192265
- name: Checkout code
193-
uses: actions/checkout@v4
266+
uses: actions/checkout@v5
194267

195268
- name: Download built Hook artifacts
196-
uses: actions/download-artifact@v4
269+
uses: actions/download-artifact@v5
197270
with:
198271
pattern: "hook-tarball-*"
199272
merge-multiple: true
@@ -262,10 +335,10 @@ jobs:
262335
steps:
263336

264337
- name: Checkout code
265-
uses: actions/checkout@v4
338+
uses: actions/checkout@v5
266339

267340
- name: Download built Hook artifacts
268-
uses: actions/download-artifact@v4
341+
uses: actions/download-artifact@v5
269342
with:
270343
pattern: "hook-tarball-*"
271344
merge-multiple: true

bash/hook-lk-containers.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ function build_all_hook_linuxkit_containers() {
77
# when adding new container builds here you'll also want to add them to the
88
# `linuxkit_build` function in the linuxkit.sh file.
99
# # NOTE: linuxkit containers must be in the images/ directory
10-
build_hook_linuxkit_container hook-bootkit "HOOK_CONTAINER_BOOTKIT_IMAGE"
11-
build_hook_linuxkit_container hook-docker "HOOK_CONTAINER_DOCKER_IMAGE"
12-
build_hook_linuxkit_container hook-udev "HOOK_CONTAINER_UDEV_IMAGE"
13-
build_hook_linuxkit_container hook-acpid "HOOK_CONTAINER_ACPID_IMAGE"
14-
build_hook_linuxkit_container hook-containerd "HOOK_CONTAINER_CONTAINERD_IMAGE"
15-
build_hook_linuxkit_container hook-runc "HOOK_CONTAINER_RUNC_IMAGE"
16-
build_hook_linuxkit_container hook-embedded "HOOK_CONTAINER_EMBEDDED_IMAGE"
10+
build_hook_linuxkit_container hook-bootkit "HOOK_CONTAINER_BOOTKIT_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
11+
build_hook_linuxkit_container hook-docker "HOOK_CONTAINER_DOCKER_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
12+
build_hook_linuxkit_container hook-udev "HOOK_CONTAINER_UDEV_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
13+
build_hook_linuxkit_container hook-acpid "HOOK_CONTAINER_ACPID_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
14+
build_hook_linuxkit_container hook-containerd "HOOK_CONTAINER_CONTAINERD_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
15+
build_hook_linuxkit_container hook-runc "HOOK_CONTAINER_RUNC_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
16+
build_hook_linuxkit_container hook-embedded "HOOK_CONTAINER_EMBEDDED_IMAGE" "${EXPORT_LK_CONTAINERS}" "${EXPORT_LK_CONTAINERS_DIR}"
1717
}
1818

1919
function build_hook_linuxkit_container() {
2020
declare container_dir="${1}"
2121
declare template_var="${2}" # bash name reference, kind of an output var but weird
2222
declare container_base_dir="images"
23+
declare export_container_images="${3:-false}"
24+
declare export_container_images_dir="${4:-/tmp}"
2325

2426
# Lets hash the contents of the directory and use that as a tag
2527
declare container_files_hash
@@ -38,13 +40,24 @@ function build_hook_linuxkit_container() {
3840
# we try to push here because a previous build may have created the image
3941
# this is the case for GitHub Actions CI because we build PRs on the same self-hosted runner
4042
push_hook_linuxkit_container "${container_oci_ref}"
43+
44+
# If export_container_images=yes then export images as tar.gzs to export_container_images_dir
45+
# This is mainly for CI to be able to pass built images between jobs
46+
if [[ "${export_container_images}" == "yes" ]]; then
47+
save_docker_image_to_tar_gz "${container_oci_ref}" "${export_container_images_dir}"
48+
fi
4149
return 0
4250
fi
4351

4452
# Check if we can pull the image from registry; if so, skip the build.
4553
log debug "Checking if image ${container_oci_ref} can be pulled from remote registry"
4654
if docker pull "${container_oci_ref}"; then
4755
log info "Image ${container_oci_ref} pulled from remote registry, skipping build"
56+
# If export_container_images=yes then export images as tar.gzs to export_container_images_dir
57+
# This is mainly for CI to be able to pass built images between jobs
58+
if [[ "${export_container_images}" == "yes" ]]; then
59+
save_docker_image_to_tar_gz "${container_oci_ref}" "${export_container_images_dir}"
60+
fi
4861
return 0
4962
fi
5063

@@ -64,9 +77,27 @@ function build_hook_linuxkit_container() {
6477

6578
push_hook_linuxkit_container "${container_oci_ref}"
6679

80+
# If export_container_images=yes then export images as tar.gzs to export_container_images_dir
81+
# This is mainly for CI to be able to pass built images between jobs
82+
if [[ "${export_container_images}" == "yes" ]]; then
83+
save_docker_image_to_tar_gz "${container_oci_ref}" "${export_container_images_dir}"
84+
fi
85+
6786
return 0
6887
}
6988

89+
function save_docker_image_to_tar_gz() {
90+
declare container_oci_ref="${1}"
91+
declare export_dir="${2:-/tmp}"
92+
93+
# Create the export directory if it doesn't exist
94+
mkdir -p "${export_dir}"
95+
96+
# Save the Docker image as a tar.gz file
97+
docker save "${container_oci_ref}" | gzip > "${export_dir}/$(basename "${container_oci_ref}" | sed 's/:/-/g').tar.gz"
98+
log info "Saved Docker image ${container_oci_ref} to ${export_dir}/$(basename "${container_oci_ref}" | sed 's/:/-/g').tar.gz"
99+
}
100+
70101
function push_hook_linuxkit_container() {
71102
declare container_oci_ref="${1}"
72103

bash/json-matrix.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ function json_matrix_find_runner() {
210210
declare -a json_items_bare=(${runner})
211211
# wrap each json_items array item in double quotes
212212
declare -a json_items=()
213-
if [[ "${runner}" != "ubuntu-latest" ]]; then # if not using a GH-hosted runner, auto-add the "self-hosted" member
214-
json_items+=("\"self-hosted\"")
215-
fi
216213
for item in "${json_items_bare[@]}"; do
217214
json_items+=("\"${item}\"")
218215
done

bash/kernel.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ function kernel_build() {
4848
else
4949
log info "DO_PUSH not 'yes', not pushing."
5050
fi
51+
52+
if [[ "${EXPORT_KERNEL_IMAGE}" == "yes" ]]; then
53+
log info "Exporting kernel image ${kernel_oci_image} to ${EXPORT_KERNEL_IMAGE_DIR}"
54+
save_docker_image_to_tar_gz "${kernel_oci_image}" "${EXPORT_KERNEL_IMAGE_DIR}"
55+
fi
5156
}
5257

5358
function kernel_configure_interactive() {

kernel/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ENV DEBIAN_FRONTEND=noninteractive
33

44
# crossbuild-essentials are pretty heavy; here we install for both architecures to maximize Docker layer hit cache rate during development, but only one will be used
55
RUN set -x && apt -o "Dpkg::Use-Pty=0" -y update && \
6-
apt -o "Dpkg::Use-Pty=0" -y install curl xz-utils gnupg2 flex bison libssl-dev libelf-dev bc libncurses-dev kmod \
6+
apt -o "Dpkg::Use-Pty=0" -y install curl xz-utils gnupg2 flex bison libssl-dev libelf-dev bc libncurses-dev kmod make \
77
crossbuild-essential-amd64 crossbuild-essential-arm64 && \
88
apt -o "Dpkg::Use-Pty=0" -y clean
99

0 commit comments

Comments
 (0)