Skip to content

Commit

Permalink
Build wkdev-sdk for non-amd64 6architectures.
Browse files Browse the repository at this point in the history
Podman allows to build multi-architecture OCI images, that combine e.g.
amd64 images + arm64 + ... in one image. Combined with qemu, one can
easily build images for foreign architectures from amd64 hosts.

Use that to extend wkdev-sdk to 'linux/arm/v7', besides the existing
'linux/amd64' support. Extend the GitHub workflow to produce
multi-architecture images. Let's see where this goes :-)
  • Loading branch information
nikolaszimmermann committed Apr 9, 2024
1 parent 151f1fd commit cc1087b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/wkdev-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ jobs:
remove-haskell: true
remove-codeql: true
remove-docker-images: true


- name: Install qemu-user-static
run: sudo apt-get -y install qemu-user-static

- name: Install podman
uses: gacts/install-podman@v1

Expand Down
9 changes: 7 additions & 2 deletions scripts/host-only/wkdev-sdk-bakery
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ argsparse_use_option =verbose "Increase verbosity of this script"

argsparse_use_option =name: "Name of container image" mandatory default:wkdev-sdk
argsparse_use_option =mode: "Operation mode: 'build', 'deploy', or 'export'" mandatory
argsparse_use_option =platforms: "Build container for given set of platforms" mandatory default:"linux/arm/v7,linux/amd64"
argsparse_use_option idle-cores: "Number of CPU cores to leave idle, when building the image" type:uint default:2

argsparse_usage_description="$(cat <<EOF
Expand All @@ -45,6 +46,7 @@ process_command_line_arguments() {
idle_cores=${program_options["idle-cores"]}

operation_mode="${program_options["mode"]}"
platforms="${program_options["platforms"]}"
[ "${operation_mode}" != 'build' ] && [ "${operation_mode}" != 'deploy' ] && [ "${operation_mode}" != 'export' ] && _abort_ "Unknown operation mode: '${operation_mode}' (valid choices are 'build', 'deploy', or 'export')"
}

Expand All @@ -56,7 +58,9 @@ build_image() {

pushd "$(get_image_directory_by_name "${container_image_name}")" &>/dev/null
timer_start
run_podman_silent_unless_verbose build --jobs $(get_number_of_cores_for_build) --tag "$(get_tag_for_build)" . || _abort_ "Container image build failed"
run_podman_silent_unless_verbose manifest rm "$(get_tag_for_build)"
run_podman_silent_unless_verbose manifest create "$(get_tag_for_manifest creation)" || _abort_ "Container image manifest creation failed"
run_podman_silent_unless_verbose build --jobs $(get_number_of_cores_for_build) --platform "${platforms}" --manifest "$(get_tag_for_build)" . || _abort_ "Container image build failed"
timer_stop
popd &>/dev/null
}
Expand All @@ -69,7 +73,8 @@ deploy_image() {

local image_directory="$(get_image_directory_by_name "${container_image_name}")"
pushd "${image_directory}" &>/dev/null || _abort_ "Switching to directory '${image_directory}' failed"
run_podman_silent_unless_verbose push "$(get_tag_for_build)" || _abort_ "Pushing to registry failed"
run_podman_silent_unless_verbose push "$(get_tag_for_build)" || _abort_ "Pushing image to registry failed"
run_podman_silent_unless_verbose manifest push "${container_image_name}:$(get_container_tag)" "docker://$(get_tag_for_build)" || _abort_ "Pushing manifest to registry failed"
popd &>/dev/null
}

Expand Down

0 comments on commit cc1087b

Please sign in to comment.