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

Multiplatform build support #140

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Multiplatform build support #140

wants to merge 3 commits into from

Conversation

larskanis
Copy link
Member

@larskanis larskanis commented Jan 2, 2025

Add support for multiple host platforms.
This way we can provide images for Intel/AMD based as well as ARM based systems.

Image building is now prefixed by the host architecture "arm" or "x86" and the local host arch is loaded after build:

rake build:arm:arm-linux-musl      # Build and load image for platform arm-linux-musl on linux/arm64
rake build:arm:arm64-darwin        # Build and load image for platform arm64-darwin on linux/arm64
rake build:arm:jruby               # Build and load image for JRuby on linux/arm64

The foreign architecture is only built:

rake build:x86:arm-linux-musl      # Build image for platform arm-linux-musl on linux/amd64
rake build:x86:arm64-darwin        # Build image for platform arm64-darwin on linux/amd64
rake build:x86:jruby               # Build image for JRuby on linux/amd64

Only docker buildx build supports multiple platforms, so that it is used now, instead of the classic docker build.

The number of images doubles with this patch, so that I get errors building all in parallel.
Therefore the number of parallel tasks should be limited like:

rake -j10 build:all

@flavorjones
Copy link
Collaborator

IMHO any buildx build command we run in this project should pass --load to import into docker. This is what I'm doing already in docker_build_cmd when RCD_USE_BUILDX_CACHE is set.

@flavorjones
Copy link
Collaborator

flavorjones commented Jan 3, 2025

It might be interesting to note here that I just pushed a github actions pipeline that builds and releases versioned images, so I no longer have to build releases locally on my (x86_64) development system.

@larskanis
Copy link
Member Author

IMHO any buildx build command we run in this project should pass --load to import into docker.

Hmm, valid point! The --load argument is not allowed with multiple architectures. But it makes sense to load at least the local architecture. I changed the rake build: tasks to also load the local archs and I removed the dedicated load: task.

I adjusted the CI tasks, so that it looks green now. But it is only running the build:x86 tasks.

Is masos-14 the only ARM64 arch on github actions? So far there's no linux arm system available, or do you know any? I'll try to get the macos-14 host system added for building images otherwise.

@flavorjones
Copy link
Collaborator

flavorjones commented Jan 3, 2025

@larskanis I poked around a bit and it looks like we might be able to apply for free credits to run ARM hardware as an open-source project: https://github.com/WorksOnArm/GitHub-Runners

Some related references:

@larskanis
Copy link
Member Author

OK, I applied for ARM based Github Runners: WorksOnArm/GitHub-Runners#9 . Let's see what they think about it.

For now macos-14 runners are not helpful for providing arm64 images: #144

@larskanis larskanis marked this pull request as ready for review January 5, 2025 15:07
@larskanis
Copy link
Member Author

@flavorjones What do you think about merging this? It allows at least to build and publish the images locally for x86_64 and aarch64.

@flavorjones
Copy link
Collaborator

@larskanis Let me just make sure I can still build everything, and if so I don't have any objections. I'll do that today, give me an hour or two.

larskanis and others added 3 commits January 5, 2025 12:27
…NG.md

And add a buildkit config which disables the garbage collection of the cache.
Our images are too many and too fat, so that it gets deleted half way otherwise.
This way we can provide images for Intel/AMD based as well as ARM based systems.

Image building is now prefixed by the host architecture "arm" or "x86" and the local host arch is loaded after build:

```
rake build:arm:arm-linux-musl      # Build and load image for platform arm-linux-musl on linux/arm64
rake build:arm:arm64-darwin        # Build and load image for platform arm64-darwin on linux/arm64
rake build:arm:jruby               # Build and load image for JRuby on linux/arm64
```

The foreign architecture is only built:

```
rake build:x86:arm-linux-musl      # Build image for platform arm-linux-musl on linux/amd64
rake build:x86:arm64-darwin        # Build image for platform arm64-darwin on linux/amd64
rake build:x86:jruby               # Build image for JRuby on linux/amd64
```

Only `docker buildx build` supports multiple platforms, so that it is used now, instead of the classic `docker build`.

The number of images doubles with this patch, so that I get errors building all in parallel.
Therefore the number of parallel tasks should be limited like:

```
rake -j10 build:all
```
@flavorjones
Copy link
Collaborator

@larskanis I rebased onto main and updated the new CI pipeline for publishing images. If this goes green, let's merge it!

@larskanis
Copy link
Member Author

Mike, do you have an arm based system locally to create a docker buildx cluster as described in the contributing doc of this PR? I've got a new quite powerful laptop due to fundraiser on https://rubyinstaller.org .

To my understanding, per platform images can not be simply appended after pushing. Either the two host platforms must be pushed by one buildx command or two images must be pushed separately with different names and then a manifest with links to them must be pushed.

The rake task release:images uses the first method. So we can not release x86 from CI and arm from local that way.

@flavorjones
Copy link
Collaborator

@larskanis Unfortunately, I do not own ARM hardware. Until we figure out how to deploy, we need to maintain the ability to ship the x86 platform images, which is why I rebased and updated the CI pipeline.

@flavorjones
Copy link
Collaborator

I'm OK merging this. Let's continue the conversation about how to deploy these images in #78?

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.

2 participants