Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify container_build.sh to add capability to use podman farm for multi-arch images #736

Merged
merged 8 commits into from
Feb 4, 2025
33 changes: 29 additions & 4 deletions container_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ parse_arguments() {
rm_after_build="true"
shift
;;
build|push)
build|push|multi-arch)
command="$1"
shift
;;
Expand All @@ -116,12 +116,24 @@ process_all_targets() {
done
}

process_multi_arch_targets() {
for i in $(cat ./multi-arch-targets.list); do
build_multi_arch "$i"
done
}

build_multi_arch() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified by passing in "farm" to build_arch()
and then doing podman $2 build ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW This is a good idea, and potentially useful for automated builds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me see.

podman farm does not like a tag on the image. So, this might be more complex.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but the script does not explicitly add the latest tag either. So this might work.

I'll tinker with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhatdan I think I succeeded in simplifying based on your request.

local target="$1"
podman farm build -t quay.io/ramalama/"$target" -f container-images/"$target"/Containerfile ./container-images
}

print_usage() {
echo "Usage: $(basename "$0") [-h|--help] [-d] <command> [target]"
echo
echo "Commands:"
echo " build Build the container images"
echo " push Push the container images"
echo " multi-arch Build and Push multi-arch images with podman farm"
echo
echo "Options:"
echo " -d Some option description"
Expand Down Expand Up @@ -149,12 +161,25 @@ main() {
print_usage
exit 1
fi
if [ "$command" = "multi-arch" ] && [ "$conman_bin" != "podman" ]; then
echo "Error: command 'multi-arch' only works with podman farm"
print_usage
exit 1
fi

target="${target:-all}"
if [ "$target" = "all" ]; then
process_all_targets "$command" "$option"
if [ "$command" = "multi-arch" ]; then
if [ "$target" = "all" ]; then
process_multi_arch_targets
else
build_multi_arch "$target"
fi
else
build "container-images/$target" "$command" "$option"
if [ "$target" = "all" ]; then
process_all_targets "$command" "$option"
else
build "container-images/$target" "$command" "$option"
fi
fi
}

Expand Down
2 changes: 2 additions & 0 deletions multi-arch-targets.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vulkan
ramalama
Loading