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 #31

Closed
msegado opened this issue Dec 7, 2021 · 15 comments · Fixed by #42
Closed

Support for ARM64 #31

msegado opened this issue Dec 7, 2021 · 15 comments · Fixed by #42

Comments

@msegado
Copy link

msegado commented Dec 7, 2021

Opening a parallel issue to overhangio/tutor#510. I'm currently able to build on an M1 MacBook by adding a few extra build requirements and environment variables:

diff --git a/tutormfe/templates/mfe/build/mfe/Dockerfile b/tutormfe/templates/mfe/build/mfe/Dockerfile
index 726d9ca..b996eea 100644
--- a/tutormfe/templates/mfe/build/mfe/Dockerfile
+++ b/tutormfe/templates/mfe/build/mfe/Dockerfile
@@ -3,7 +3,18 @@ FROM docker.io/node:12-bullseye-slim AS base
 RUN apt update \
   && apt install -y git \
     # required for cwebp-bin
-    gcc git libgl1 libxi6 make
+    gcc git libgl1 libxi6 make \
+    # additionally required for gifsicle, mozjpeg, and optipng
+    autoconf libtool pkg-config zlib1g-dev \
+    # additionally required for node-sass
+    python g++
+
+# Required for building optipng on M1
+ENV CPPFLAGS=-DPNG_ARM_NEON_OPT=0
+
+# Required for avoiding failed frontend-app-learning build due to missing binary on M1
+# (breaks pact tests)
+ENV PACT_SKIP_BINARY_INSTALL=true
 
 RUN mkdir -p /openedx/app /openedx/env
 WORKDIR /openedx/app

Unfortunately, using PACT_SKIP_BINARY_INSTALL is a hack that will break any Pact tests, so it's not really suitable to merge in. I don't see much alternative until there's an ARM binary for Pact though. Relevant issue: pact-foundation/pact-js-core#347

@regisb
Copy link
Contributor

regisb commented Dec 14, 2021

Can we get rid of pact upstream, in Open edX?

@msegado
Copy link
Author

msegado commented Dec 14, 2021

Seems unlikely... it looks like they just added it this summer: openedx/frontend-app-learning#510

@regisb
Copy link
Contributor

regisb commented Dec 14, 2021

My feeling is that it's going to be easier to make a contribution to pact than to fix the issue here.

@TimothyJones
Copy link

Pact maintainer here - pact works fine on an M1 macbook running OSX because of rosetta. It won't work if you are running a different OS on that chipset, though.

@kdmccormick
Copy link
Contributor

@msegado I opened a PR against frontend-app-learning to switch pact from being a base dependency to a devDependency: openedx/frontend-app-learning#823. Do you know if that would stop Pact from breaking npm build? I would try myself but I'm on an Intel machine.

@kdmccormick
Copy link
Contributor

It turns out that my PR linked above might fix the Pact issue for production image builds (assumingNODE_ENV=production when we run npm install for the production image), but we'd still be left with a broken build for the development image. I'm going to get it merged, but I think we'll still need an upstream Pact fix :/

@yarons
Copy link

yarons commented Feb 20, 2022

@kdmccormick I know that there's an option to make some Dockerfile conditionals based on BUILDTARGET so there could be distinct pakcages for each platform (in this case an addition).

@jigsawlabs-student
Copy link

I am running into an issue with the following:

FROM docker.io/node:12-bullseye-slim AS base

RUN apt update \
  && apt install -y git \
    # required for cwebp-bin
    gcc git libgl1 libxi6 make \
    # additionally required for gifsicle, mozjpeg, and optipng
    autoconf libtool pkg-config zlib1g-dev \
    # additionally required for node-sass
    python g++
    
# Required for avoiding failed frontend-app-learning build due to missing binary on M1
# (breaks pact tests)
ENV PACT_SKIP_BINARY_INSTALL=true

RUN mkdir -p /openedx/app /openedx/env

However, when I run tutor images build mfe I get the following error:

#71 42.45 ERROR in ./src/index.scss
#71 42.45 Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
#71 42.45 ModuleBuildError: Module build failed (from ./node_modules/image-webpack-loader/index.js):
#71 42.45 Error: Cannot find module 'gifsicle'
#71 42.45 Require stack:

Per suggestions on the Internet, tried updating my Dockerfile to the following to install dh-autoreconf, but still run into the same error:

RUN apt update \
  && apt install -y git \
    # required for cwebp-bin
    gcc git libgl1 libxi6 make \
    # additionally required for gifsicle, mozjpeg, and optipng
    autoconf libtool pkg-config zlib1g-dev \
    # additionally required for node-sass
    python g++
    
RUN apt-get install dh-autoreconf

@yarons
Copy link

yarons commented Feb 28, 2022

@jigsawlabs-student Please correct me if I'm wrong but the gifsicle Node package requires the gifsicle binary.

AFAICT gifsicle binary support aarch64 yet the Node package doesn't, did you notice the same thing?

@jigsawlabs-student
Copy link

jigsawlabs-student commented Feb 28, 2022

@yarons Ok, so I was able to resolve this.

For the gifsicle, I ran:

brew install gifsicle on my mac

I then ran into an error related to pact binary install. It turned out that my mfe image didn't have the correct updates.

I went to /Library/Application Support/tutor/env/plugins/mfe/build and updated the dockerfile to have:

RUN apt update \
  && apt install -y git \
    # required for cwebp-bin
    gcc git libgl1 libxi6 make \
    # additionally required for gifsicle, mozjpeg, and optipng
    autoconf libtool pkg-config zlib1g-dev \
    # additionally required for node-sass
    python g++
    
# Required for avoiding failed frontend-app-learning build due to missing binary on M1
# (breaks pact tests)
ENV PACT_SKIP_BINARY_INSTALL=true

as described above.

Then, referencing this comment, I ran tutor images build mfe, and then tutor local init.

Then from there, ran tutor dev runserver lms, and was able to access my site at http://local.overhang.io:8000/

@yarons
Copy link

yarons commented Mar 1, 2022

@jigsawlabs-student I just want to mention you're awesome!

Yet, I have to ask, installing some extras locally is the only solution?
(I'm asking this because of K8s mainly).

@jigsawlabs-student
Copy link

Hmm..I don't know...but glad this helped!

@kdmccormick
Copy link
Contributor

Sorry I haven't been more responsive @yarons and @jigsawlabs-student. I'm out of office until 3/17 but I'm looking forward to catching up on what you've found right after I get back.

regisb added a commit that referenced this issue Mar 14, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

Close #31.
regisb added a commit that referenced this issue Mar 14, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

Close #31.
@regisb
Copy link
Contributor

regisb commented Mar 14, 2022

@jigsawlabs-student @yarons @msegado can you please have a look at this PR? #42

@regisb
Copy link
Contributor

regisb commented Mar 14, 2022

And maybe also @bradenmacdonald? thanks!

regisb added a commit that referenced this issue Apr 15, 2022
Additional requirements are required, and we cannot download the pact binary on
arm64: pact-foundation/pact-js-core#264

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

Successfully merging a pull request may close this issue.

6 participants