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

Conversation

cgruver
Copy link
Collaborator

@cgruver cgruver commented Feb 4, 2025

Modified container_build.sh -

  1. Add multi-arch as a command
  2. Add multi-arch-targets.list to be processed if $target == all

Usage:

./container_build.sh multi-arch all - Uses podman farm to build all of the images in multi-arch-targets.list

./container_build.sh multi-arch vulkan - Usespodman farm to build quay.io/ramalama/vulkan.

Summary by Sourcery

Add support for building multi-arch images using podman farm.

New Features:

  • Building multi-architecture container images is now supported through the multi-arch command in container_build.sh script.

Build:

  • Add multi-arch command to container_build.sh to build multi-arch images using podman farm.
  • Add support for building all multi-arch images defined in multi-arch-targets.list.
  • Set default registry path to quay.io/ramalama.

Copy link
Contributor

sourcery-ai bot commented Feb 4, 2025

Reviewer's Guide by Sourcery

This pull request introduces the capability to build multi-architecture container images using podman farm. It adds a new multi-arch command to the container_build.sh script, allowing users to build images for multiple architectures simultaneously. It also updates the Makefile to include a multi-arch target.

Sequence diagram for multi-arch build process

sequenceDiagram
    participant User
    participant Script as container_build.sh
    participant Podman as Podman Farm
    participant Registry as Container Registry

    User->>Script: ./container_build.sh multi-arch target
    Note over Script: Validate command & environment
    alt target == 'all'
        Script->>Script: Process all targets with .multi-arch flag
    else specific target
        Script->>Script: Process single target
    end
    Script->>Podman: podman farm build
    Note over Podman: Build for multiple architectures
    Podman->>Registry: Push multi-arch image
Loading

File-Level Changes

Change Details Files
Added a new multi-arch command to container_build.sh to build multi-architecture images using podman farm.
  • Added multi-arch as a valid command.
  • Implemented the multi-arch command using podman farm build.
  • Added a check to ensure podman is used when the multi-arch command is invoked.
  • Added a check for a .multi-arch file to determine if multi-arch build should be executed.
container_build.sh
Updated the Makefile to include a multi-arch target.
  • Added a multi-arch target to the Makefile.
  • The new target executes the container_build.sh script with the multi-arch command.
Makefile
Modified the script to allow overriding the registry path using the REGISTRY_PATH environment variable.
  • Replaced hardcoded registry path with the REGISTRY_PATH variable.
  • Set a default value for REGISTRY_PATH to quay.io/ramalama.
container_build.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 4, 2025

@rhatdan @ericcurtin

WDYT?

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.

Signed-off-by: Charro Gruver <[email protected]>
@ericcurtin
Copy link
Collaborator

ericcurtin commented Feb 4, 2025

It's fine, but maybe the list should exclude certain targets rather than include certain targets. Ideally, everything should be built multi-arch except for "rocm" and "asahi" if they cause issues. Interestingly, "asahi" might build fine for x86_64, because the Asahi community do some GPU x86_64 stuff via muvm, so there's actually some rare use-cases for that.

So maybe even just try and exclude "rocm" (no aarch64 rpms available for that platform). Generally multi-arch should always be built except in exceptional circumstances. (not taking s390 and ppc into account for a moment)

A separate list file maybe isn't necessary either, but happy to leave that up to you.

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 4, 2025

It's fine, but maybe the list should exclude certain targets rather than include certain targets. Ideally, Everything should be built multi-arch except for "rocm" and "asahi" if they cause issues. Interestingly, "asahi" might build fine for x86_64, because they do some GPU x86_64 stuff via muvm, so there's actually some rare use-cases for that.

So maybe even just try and exclude "rocm". Generally multi-arch should always be built except in exceptional circumstances. (not taking s390 and ppc into account for a moment)

A separately list file maybe isn't necessary either, but happy to leave that up to you.

Intel probably doesn't make sense for multi-arch either.

But, I like the idea of an exclude list too. I'll tinker with it.

@ericcurtin
Copy link
Collaborator

Yeah sorry intel too :)

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 4, 2025

@ericcurtin WDYT?

I trigger the podman farm build based on the presence of a .multi-arch file in the container image folder.

…e image folder to trigger podman farm build

Signed-off-by: Charro Gruver <[email protected]>
@cgruver cgruver marked this pull request as ready for review February 4, 2025 20:50
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @cgruver - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please document the purpose and requirements of the .multi-arch file in the script's usage information, as it's currently not clear why certain images might be skipped during multi-arch builds.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

container_build.sh Show resolved Hide resolved
container_build.sh Outdated Show resolved Hide resolved
@ericcurtin
Copy link
Collaborator

This is mergeable @cgruver but again, I'd flip it to be exclusive rather than inclusive, it's an exception when we don't do multi-arch with the exceptions being rocm, intel (and maybe asahi, but asahi actually use the x86_64 GPU drivers on muvm as I said before).

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 4, 2025

This is mergeable @cgruver but again, I'd flip it to be exclusive rather than inclusive, it's an exception when we don't do multi-arch with the exceptions being rocm, intel (and maybe asahi, but asahi actually use the x86_64 GPU drivers on muvm as I said before).

@ericcurtin Do you prefer a .skip-multi-arch file in the image folder, or just code into the script which ones to skip?

@ericcurtin
Copy link
Collaborator

This is mergeable @cgruver but again, I'd flip it to be exclusive rather than inclusive, it's an exception when we don't do multi-arch with the exceptions being rocm, intel (and maybe asahi, but asahi actually use the x86_64 GPU drivers on muvm as I said before).

@ericcurtin Do you prefer a .skip-multi-arch file in the image folder, or just code into the script which ones to skip?

If it was me I'd code it in, people are gonna wonder what the mystery files are about (and they are hidden), but I'll leave it upto you.

I just want to get people into the habit of building multi-arch. Like it's very easy to think Nvidia is x86-only, as one example, but it's actually not. And an eGPU can connect to multiple arches also.

@ericcurtin
Copy link
Collaborator

Plus there's less platforms to skip than include, at present it's max 3 we should skip for multi-arch

@cgruver
Copy link
Collaborator Author

cgruver commented Feb 4, 2025

This is mergeable @cgruver but again, I'd flip it to be exclusive rather than inclusive, it's an exception when we don't do multi-arch with the exceptions being rocm, intel (and maybe asahi, but asahi actually use the x86_64 GPU drivers on muvm as I said before).

@ericcurtin Do you prefer a .skip-multi-arch file in the image folder, or just code into the script which ones to skip?

If it was me I'd code it in, people are gonna wonder what the mystery files are about (and they are hidden), but I'll leave it upto you.

I just want to get people into the habit of building multi-arch. Like it's very easy to think Nvidia is x86-only, as one example, but it's actually not. And an eGPU can connect to multiple arches also.

Done and done. :-) I added a case to exclude intel-gpu and rocm

@cgruver cgruver requested a review from rhatdan February 4, 2025 21:42
@rhatdan
Copy link
Member

rhatdan commented Feb 4, 2025

LGTM

@rhatdan rhatdan merged commit 10321b0 into containers:main Feb 4, 2025
12 checks passed
@cgruver cgruver deleted the podman-farm-script branch February 4, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants