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

feat(docker): make containers multi-arch #343

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

Conversation

AtomicFS
Copy link
Collaborator

@AtomicFS AtomicFS commented Sep 25, 2024

This makes all of our containers multi-architectural / multi-platform and fixes #341 .

At the moment we only support x86_64 (aka amd64) and arm64 (specifically arm64 v8).

Todo:

  • uroot (this was no work)
  • linux (this was easy)
  • coreboot (took some effort but works)
  • edk2 (this is pain)
    • build the toolchains on the fly for non-x86 architectures (first use by user)
      • this is kinda difficult to test at the moment

There is a lot to comprehend, so here are some notes as to why:

  • u-root and linux are OK to build the "normal way", however with edk2 and coreboot I get errors when trying to compile to tool-chains - I suspect the problem to be native emulation not supporting all of the instructions required
    • building x86 on x86 machine and arm64 on arm64 works fine, but building arm64 on x86 machine is broken (and vice versa)
  • this means that I cannot build edk2 or coreboot multi-arch container on single x86 machine as I can u-root or linux
  • I looked into cross-compilation - aka cross-compile the cross-compilation tool-chains ... well that did not go well
    • it should be possible, but it seems like a long process not worth the time investment
  • one way would be to build each arch-container separately (x86 part on x86 machine and arm64 part on arm64 machine), publish them separately and then publish hand-crafted manifest connecting them together ... (see The hard way with docker manifest in Multi-arch build and images, the simple way
  • but we can avoid all of that with simply compiling the tool-chains separately on their respective machines and then just copy files into single multi-arch container (which can be done without any problems with simple native emulation)
  • one advantage of separate tool-chain compilation is that this way we can cache the compiled tool-chains for coreboot and speed up the build by one order of magnitude (normally they take around 1 hour to compile)
  • as I was running out of disk-space for coreboot docker container I decided to use upx to compress the toolchain reducing the size from around 1.5 GB down to 1.0 GB (as a nice side-effect the whole container is smaller)
  • as it stands now, we are not testing if the multi-arch containers work on other than x86 architectures, since it is not really possible right now. We can only verify that the new changes did not break existing functionality.

This is the final PR in the multi-arch saga, which contains breaking changes.

@github-actions github-actions bot added feature New feature or request github_actions Pull requests that update GitHub Actions code python Pull requests that update Python code labels Sep 25, 2024
@AtomicFS AtomicFS added the docker docker related label Sep 25, 2024
@AtomicFS AtomicFS force-pushed the feat/multi-arch-docker branch 5 times, most recently from 434ec0a to 992d9d5 Compare September 30, 2024 08:55
@github-actions github-actions bot added the testing Testing related label Sep 30, 2024
@AtomicFS AtomicFS force-pushed the feat/multi-arch-docker branch 9 times, most recently from ac0695e to 2c343be Compare October 7, 2024 16:41
@AtomicFS AtomicFS force-pushed the feat/multi-arch-docker branch 6 times, most recently from 634f911 to aa7550d Compare October 9, 2024 15:17
@AtomicFS AtomicFS force-pushed the feat/multi-arch-docker branch 15 times, most recently from 99ffe7f to 96ed75b Compare October 27, 2024 08:12
@AtomicFS
Copy link
Collaborator Author

The linting issue is a known bug

@AtomicFS AtomicFS force-pushed the feat/multi-arch-docker branch 2 times, most recently from a2f69a2 to 568d95d Compare October 28, 2024 12:29
@AtomicFS AtomicFS changed the title feat(docker): make containers multi-arch feat(docker): make containers multi-arch (WIP) Oct 30, 2024
@AtomicFS AtomicFS mentioned this pull request Oct 30, 2024
BREAKING CHANGE: this commit changes how Docker containers are build

Signed-off-by: AtomicFS <[email protected]>
- since we no longer compile the toolchains, we can greatly simplify the
  dockerfile - we no longer need multi-stage build

Signed-off-by: AtomicFS <[email protected]>
- this is necessary to support multi-architectural use

Signed-off-by: AtomicFS <[email protected]>
@AtomicFS AtomicFS changed the title feat(docker): make containers multi-arch (WIP) feat(docker): make containers multi-arch Oct 31, 2024
run: |
cd coreboot
COREBOOT_HASH="$( git rev-parse --short HEAD )"
echo "${COREBOOT_HASH}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of outputting the content of the variable here? Just for debugging? And in the next step you out CACHE_KEY=${CACHE_KEY} aka KEY=VALUE and here just VALUE. Was that done on purpose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker docker related documentation Improvements or additions to documentation feature New feature or request github_actions Pull requests that update GitHub Actions code module/coreboot module/edk2 module/linux python Pull requests that update Python code testing Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add multi-architecture support (arm64)
2 participants