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

Add support for arm64 build (tested on Mac M1) #573

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Add support for arm64 build (tested on Mac M1) #573

merged 1 commit into from
Mar 19, 2024

Conversation

PCatinean
Copy link
Contributor

This PR introduces support for ARM builds and has been tested on Mac M1, a basic rundown on the changes:

  1. Download resources from the same release location but use the targeted architecture
  2. Update GEOIP_UPDATER_VERSION to the latest version as arm64 builds are also available
  3. Force wkhtmltopdf version to 0.12.6 since it also has an arm64 build (fail build otherwise)
  4. Automatically upgrade odoo requirements.txt for arm64 build and force gevent==21.12.0 and greenlet==1.1.0 (minimum versions required for a successful build otherwise cython will thrown an error (i.e rc/gevent/_gevent_cgreenlet.pxd:181:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.)

@ap-wtioit
Copy link
Contributor

this should fix / implements #567 and #342 for version 16.0

@bosd
Copy link

bosd commented Dec 24, 2023

Thanks for this PR, Could you also make one for V14?

@pedrobaeza
Copy link
Member

Please rebase and solve conflicts, and do the pre-commit fixes in the same commit that introduces the error.

@PCatinean
Copy link
Contributor Author

PR rebased and I also added arm builds for Odoo version 14, 15 and 17. I have build tested all of them locally on Mac M1

@pedrobaeza
Copy link
Member

Thanks for it. Seems OK. The only point I don't know right now is where to indicate that the pushed build is for both platforms. Do you know it?

@PCatinean
Copy link
Contributor Author

I think we need to adjust the ./hooks/build script or use the available github actions but either way it seems docker buildx is required for multi-platform builds: https://docs.docker.com/build/ci/github-actions/multi-platform.

I will make another branch on my fork and link it to my docker hub then do some tests there and later propose those changes to this PR as well.

In the meantime people can use this PR to build the *-onbuild image locally.

@bosd
Copy link

bosd commented Dec 26, 2023

Would like to functional test this, I have an arm server available.
But I'm light on experience.

How can this be tested locally? 😊 👼
I've tried copying the contents of the 14.0-dockerfile into my odoo/Dockerfile of the doodba-copier-template but produces an error.


 > [base  8/10] COPY entrypoint.d common/entrypoint.d:
------
Dockerfile:90
--------------------
  88 |     COPY build.d common/build.d
  89 |     COPY conf.d common/conf.d
  90 | >>> COPY entrypoint.d common/entrypoint.d
  91 |     RUN mkdir -p auto/addons auto/geoip custom/src/private \
  92 |         && ln /usr/local/bin/direxec common/entrypoint \
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref c65c21a4-8130-4ed7-9f2c-00eafd782e20::tw9or30qgl9vfkb72ljrcqszc: "/entrypoint.d": not found

@PCatinean
Copy link
Contributor Author

PCatinean commented Dec 27, 2023

@bosd I am not sure what is your setup but here are a few steps on how to do this, if you need more details I think it's better to open a github discussion rather than continuing on this PR.

  1. First you need to clone my branch locally git clone https://github.com/pledra/doodba.git -b arm-builds doodba-arm
  2. Here you use either an ARM computer when building and just run something like docker build -f 14.0.Dockerfile . -t doodba:14.0-arm-onbuild or if you are not on ARM then you need to use docker buildx https://docs.docker.com/engine/reference/commandline/buildx/ and specify arm64 platform when building
  3. Follow the steps at https://github.com/Tecnativa/doodba-copier-template to create a new template
  4. After you have finished all the steps go into scaffolding/odoo/Dockerfile and replace FROM ghcr.io/tecnativa/doodba:${ODOO_VERSION}-onbuild with the above built image doodba:14.0-arm-onbuild
  5. Now when you build the image locally from the scaffolding it should use the arm base image.

One last thing to note and this will be probably a PR on other repositories, for the development environment some support images are missing arm builds as well.

@bosd
Copy link

bosd commented Dec 27, 2023

@PCatinean Thanks!!
I managed to build it 🎉
Had to mod the 14.0 and 15.0 dockerfiles to WKHTMLTOPDF_VERSION=0.12.6.1

One last thing to note and this will be probably a PR on other repositories, for the development environment some support images are missing arm builds as well.

Indeed on the dev env I got an error This error is because there is no image build for linux/arm64/v8 platform. on pgweb and the proxy.
For the proxys whitelist there is a pr in: Tecnativa/docker-whitelist#15
I'm a bit puzzled on the pgweb one, as pgweb supports arm,

@PCatinean
Copy link
Contributor Author

@bosd happy to hear it worked. Yes I will have to take a look at the other images as well, for the wkhtmltopdf version it is a build argument so you can just do --build-arg WKTHTMLTOPDF_VERSION=version and it will use that no need to change the original file

@bosd
Copy link

bosd commented Dec 27, 2023

Yeah, We're getting there to arm support..
But there is still some todo on devel env.: after inv start
The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
But that isunrelated to this pr 😉

root@debian:~/doodarm# inv start
WARN[0000] mount of type `volume` should not define `bind` option 
WARN[0000] mount of type `volume` should not define `bind` option 
[+] Running 4/0
 ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s 
 ✔ Volume "doodarm_db"                                                                                                                               Created0.0s 
[+] Running 5/5odarm-db-1                                                                                                                            Crea ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Crea ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Crea ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Crea ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Star ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Star ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea[+] Running 5/5odarm-db-1                                                                                                                            Star ✔ Volume "doodarm_filestore"                                                                                                                        Created0.0s e requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s ✔ Volume "doodarm_db"                                                                                                                               Created0.0s iner doodarm-odoo-1                                                                                                                          Crea ✔ Container doodarm-db-1                                                                                                                            Started0.0s 
 ! db The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s 
 ✔ Container doodarm-odoo-1                                                                                                                          Started0.1s 


so you can just do --build-arg WKTHTMLTOPDF_VERSION=version and it will use that no need to change the original file

Thanks, that will likely work. Well from usability point of view, personally I would prefer to set it by default to the arm supported version instead of throwing an error.

Copy link

@bosd bosd left a comment

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza
Copy link
Member

Any news about how to publish this for merging it?

@bosd
Copy link

bosd commented Dec 30, 2023

Any news about how to publish this for merging it?

Not sure what you mean by this.
My usability comment is non blocker. I'd say it is ready for merge.

@pedrobaeza
Copy link
Member

It's not for you, @bosd. I mean this comment: #573 (comment)

@bosd
Copy link

bosd commented Jan 21, 2024

ping @PCatinean Can you attend to pedro's question?

@PCatinean
Copy link
Contributor Author

@pedrobaeza here are the latest changes that add for support of multi-arch builds. The following adjustments have been made:

  1. In order to not complicate the CI process by passing explicit arguments and also make the images work out of the box, version 14.0 and 15.0 get a "Forcing wkhtmltopdf version to 0.12.6.1" message for ARM64 builds (otherwise they wouldn't work anyway).
  2. The hooks dir has been removed since the scripts inside (push & build) are deprecated. There are github actions that achieve the same result, have more support and also handle the docker buildx (required for building for other architectures).
  3. The platforms variable is configurable per odoo version and can be extended with more architectures in the future.

The arm64 builds are a bit slow around this step Building wheel for libsass (setup.py):. I am sure it can be optimized but for the time being they are increasing the build time a bit.

Tests have been made locally and pushed to: https://hub.docker.com/repository/docker/pledra/doodba/tags?page=1&ordering=last_updated. The architectures available are shown there and when doing a regular pull it should reconcile with the architecture of the system automatically.

If there are any other tests I can make or info to share please let me know.

@PCatinean
Copy link
Contributor Author

Hi @pedrobaeza so the PR is finally ready.

After a few tests I discovered that the execution time of both test and build (now with 2 platforms) in one single job hit a timeout or resource limit of the github runner. I have now separated the test and build-push into two separate jobs. I think it's better/cleaner this way anyhow since tests alone take around 40 minutes. Given the test job also builds the image to run the tests (i think) we can even set the "build & push" job to run only when merged in master and thus reducing the pipeline time and avoid building on PR's alone.

I tested locally on my fork with the same github variable names, the only difference is the github repo name "pledra/doodba" instead of "tecnativa/doodba".

PR: https://github.com/pledra/doodba/pull/1
Docker repo: https://hub.docker.com/repository/docker/pledra/doodba/tags?page=1&ordering=last_updated

On the PR the test and build ran but only when merged to master did the push also get activated.

Hope this work for you :)

@bosd
Copy link

bosd commented Feb 19, 2024

@pedrobaeza Is this one ok now? Ready for merge 🙏

@PCatinean
Copy link
Contributor Author

@pedrobaeza since this is a bigger change to the workflow if you feel uncomfortable with it we can configure a different branch or a separate repo to push to inside this PR and test there before pushing to master.

@bosd
Copy link

bosd commented Mar 12, 2024

Any update? 👀

@PCatinean
Copy link
Contributor Author

Until there is some time to review this PR I will maintain my fork and rebase every now and then to make the ARM build available for anyone who needs them:

https://github.com/pledra/doodba
https://hub.docker.com/repository/docker/pledra/doodba

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Sorry, lack of time.

@pedrobaeza pedrobaeza merged commit 691b28e into Tecnativa:master Mar 19, 2024
11 checks passed
@pedrobaeza
Copy link
Member

Please check when built if everything is OK and pushed, or tell me back if not.

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.

4 participants