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

Support for ARM64 for docker image #1180

Open
munyoudoum opened this issue Jan 18, 2022 · 28 comments
Open

Support for ARM64 for docker image #1180

munyoudoum opened this issue Jan 18, 2022 · 28 comments
Labels
enhancement New feature or request nostale This issue or pull request is not stale, keep it open

Comments

@munyoudoum
Copy link

munyoudoum commented Jan 18, 2022

Currently only see linux/amd64 on https://hub.docker.com/r/megalinter/megalinter/tags

It would be amazing to have arm64 also

Thanks

@munyoudoum munyoudoum added the enhancement New feature or request label Jan 18, 2022
@nvuillam
Copy link
Member

It's probably possible :) https://medium.com/swlh/using-github-actions-to-build-arm-based-docker-images-413a8d498ee

But will take some time if I have to do it myself because of my little available time these days ^^

We could have "mirror" images with -arm , like megalinter/megalinter:arm-v5 , arm-beta , etc ...

Do you have Github Actions knownledge ? I would glady accept a PR :)

@echoix
Copy link
Collaborator

echoix commented Jan 30, 2022

Today I tried to build an arm64 docker image.

The solution to build multiple docker images (same name, but different CPU architectures combined) is to use buildx.
Since it is running in a shell script and not in pure GitHub action, then the setup is to do

docker buildx create --use

Then, replacing

docker build --no-cache --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${BUILD_REVISION}" --build-arg "BUILD_VERSION=${BUILD_VERSION}" -t "${CONTAINER_URL}:${IMAGE_VERSION}" -f "${DOCKERFILE_PATH}" . 2>&1

with

docker buildx build --platform linux/amd64,linux/arm64 --no-cache --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${BUILD_REVISION}" --build-arg "BUILD_VERSION=${BUILD_VERSION}" -t "${CONTAINER_URL}:${IMAGE_VERSION}" -f "${DOCKERFILE_PATH}" . 2>&1

should do the work (replacing all the places with build by buildx build and platforms.

However, there is some prep work to make everything work.
Currently, in the Dockerfile some tools are downloaded with an explicit url targeting x86_64 or amd64, etc. There must be a way of defining different urls or download links per tool. Not all tools name arm64 the same way, so no variable in URL works for everyone (some call it aarch64 for example).
Also, some tools, like dotenv-linter have problems building for arm64 on Docker because of a long-standing problem of a rust crypto library, Ring. I tried to see if I could fix it myself, but it seems harder than it seems.

I also tried building the Dockerfile locally on a Raspberry Pi 4, but it failed when it came time to pull FROM checkmarx/kics:alpine as kics since my Raspberry Pi 4 was not installed on a 64-bit OS, so it reported armv7l, asking linux/arm/v7, which they don't publish.

So, I'll try to come back with a TODO list of linters to fix the install to get a building image, and one day we could talk about actual failing linters. In the meantime, some prep work to integrate having different URL installers should be done. Most of the Docker tools are ok, especially when they target only alpine, or many arch are available.

@nvuillam
Copy link
Member

Thank a lot for your analysis :)

About not compliant linters, we could eventually flag them in descriptors so they are simply not added within arm64 images

Story to be continued... :)

@echoix
Copy link
Collaborator

echoix commented Jan 30, 2022

I just hope that to start, at least one flavour would have all linters working... We'll see :)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Mar 2, 2022
@echoix
Copy link
Collaborator

echoix commented Mar 2, 2022

I'd like to keep it as a milestone task, but it'll be over the next two months though... I'm still thinking it out regularly

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Mar 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 2, 2022

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Apr 2, 2022
@natpicone
Copy link

really needed

@echoix
Copy link
Collaborator

echoix commented Apr 12, 2022

@natpicone What linters or flavours do you use in priority? It is not a simple task to have MegaLinter on arm, since we would have to ask for changes in many of the included projets.
Pure Python linters should run without any problems, but we still need to figure out how to built multi arch image Dockerfiles.

@nvuillam nvuillam added nostale This issue or pull request is not stale, keep it open and removed O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity labels Apr 12, 2022
@natpicone
Copy link

@natpicone What linters or flavours do you use in priority? It is not a simple task to have MegaLinter on arm, since we would have to ask for changes in many of the included projets. Pure Python linters should run without any problems, but we still need to figure out how to built multi arch image Dockerfiles.

I'm currently using ruby and javascript ones; running them on my M1 is a pain because sometimes docker x86 emulation crashes or takes a lot of time.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label May 15, 2022
@Kurt-von-Laven Kurt-von-Laven removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label May 15, 2022
@Kurt-von-Laven
Copy link
Collaborator

For some reason the bot didn’t honor the nostale label, so I removed the stale label manually.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Jun 15, 2022
@bdovaz
Copy link
Collaborator

bdovaz commented Jun 23, 2022

I have started working on it: #1553

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Jun 24, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Jul 24, 2022
@github-actions github-actions bot closed this as completed Aug 8, 2022
@echoix
Copy link
Collaborator

echoix commented Aug 8, 2022

No stale, the other PR is not finished

@nvuillam nvuillam removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Aug 8, 2022
@nvuillam nvuillam reopened this Aug 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Sep 8, 2022
@echoix echoix removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Sep 8, 2022
@jokay
Copy link
Contributor

jokay commented Dec 13, 2023

@nvuillam any progress on this one?

@nvuillam
Copy link
Member

@jokay there was a PR which was quite progressing, but other maintainers are following the topic and probably could tell you more :)

Cc @echoix @Kurt-von-Laven @bdovaz

@bdovaz
Copy link
Collaborator

bdovaz commented Dec 13, 2023

Well, the truth is quite scattered...

I started with #2273 but I found several blocks....

@waterfoul followed with #2549 (which I really miss what was trying to be achieved here) but has not given signs of life for some time and it's a pity because it looks like good progress.

And finally @echoix is with #3193 which allows to unlock some problem.

@nvuillam
Copy link
Member

The summary seems to be "Someday in a MegaLinter v8" ^^

@bdovaz
Copy link
Collaborator

bdovaz commented Dec 28, 2023

@echoix now that #3193 has been merged what do you see as the next step? I still don't understand what we were trying to solve in #2549 and if it's necessary for my PR #2273 ...

@echoix
Copy link
Collaborator

echoix commented Dec 28, 2023

@bdovaz it would allow to run a something like https://github.com/echoix/megalinter/pull/28/files#diff-c40ecec00fa976e23241a7188bb7ca5e905d288775c1286f81dd85d1e07ba2f0R41-R48 (and the changes that I made under that to push to that)
without failing from out of size when testing (because it pulled a second container). So, having this service means we can push a locally built image (even if built for multiple platforms), and still have it available in the same run. This solves the error that we weren't able to "load" a multiplatform image to test test it in the same run.

But we will need to fight against the disk space, since at one point, when pushing the built image, will have the space used by docker buildx plus the space used by that local registry that it is copied to. Multi-platform image means that we will have 2x the space used. (4x the size I'm of the image). I can image a way that we can lower the max disk space used to 3x the image size, by building one after the other and cleaning buildx in between, but still. That will be an issue to figure out. But at least it should allow us to advance a bit more.

Maybe we could start by merging #2549 into #2273, (without having everything working yet), apply the changes that use the metadata action, then we could add the local registry and really start building and work around the failures of missing space or builds too long/too big.

@bdovaz
Copy link
Collaborator

bdovaz commented Jan 4, 2024

@echoix I think you misunderstood me, I was referring to #2549 which is the one I don't know what I was trying to solve and it's half-finished and @waterfoul gives no sign.

And I don't know what improves / solves over my PR (#2273).

@echoix
Copy link
Collaborator

echoix commented Jan 5, 2024

@echoix I think you misunderstood me, I was referring to #2549 which is the one I don't know what I was trying to solve and it's half-finished and @waterfoul gives no sign.

And I don't know what improves / solves over my PR (#2273).

#2549 had some pretty nice optimizations, Dockerfile organization and patterns that would be a shame to loose. It solved multiple problems (that it had) when he was doing it. I know it might be impossible to do a real "merge" because of how fast the repo changes, but the ideas are still clearly there.

@mbyio
Copy link

mbyio commented Jul 4, 2024

Hi, I just wanted to chime in to note that this issue might be a little more relevant now, due to the release of ARM64 GitHub Actions runners.

@javydekoning
Copy link

The summary seems to be "Someday in a MegaLinter v8" ^^

Looks like it didn't happen? 🫣

@nvuillam
Copy link
Member

@javydekoning it did not happen ^^

If you want to invest time on it with us you are welcome to help the "Someday in a MegaLinter v9" happen 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nostale This issue or pull request is not stale, keep it open
Projects
None yet
Development

No branches or pull requests

9 participants