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

Node workflow - build linux arm64 in a container #520

Merged
merged 46 commits into from
Dec 9, 2022

Conversation

acalcutt
Copy link
Collaborator

@acalcutt acalcutt commented Oct 1, 2022

This is an addition to the node release workflow to add linux-arm64 binaries. linux arm64 binaries are needed when running inside docker on a arm64 system. If we could get a Linux arm64 runner here, we could do this simpler because we could just add it into the OS matrix and be done, however I found this way to do it on what we have right now.

To do this build, I made the following

1.) A docker ubuntu focal 20.04.05 image bulder, made to be run inside the maplibre-native root directory, which pulls in all the local repo files, and sets an entrypoint script 'platform\node\scripts\docker_build_entrypoint.sh'

2.) In the 'docker_build_entrypoint.sh' I added all the linux build commands, so when the docker runs it builds all the lib files. when it completes it copies the lib files back to the host.

3.) I made a workflow which uses QEMU to emulate arm64. It first builds the docker image. It then runs the docker image, which generates binaries in an emultated linux\arm64 ubuntu focal, then it copies them back to the local lib fold on the host. It then uses node-pre-gyp to publish the arm64 libs like the normal process does.

This is running on ubuntu-latest right now, so it is a bit slow. It took about 3hr and 20min for a build. I initially was trying to run this on our macos-arm, but I could not get it to run the docker after many attempts (see the commit history)

@acalcutt
Copy link
Collaborator Author

acalcutt commented Oct 3, 2022

I'm going to do another test on the macos-arm and see if i can get it working with docker-composer added. I did try installing docker with brew already, but maybe not having docker-composer made it fail.

The time right now is mainly the QEMU emulation of arm64....just makes it slow. If we had a real linux arm runner we could just add it as another build in the regular workflow.

@birkskyum
Copy link
Member

birkskyum commented Oct 4, 2022

Thanks for trying it out. It's likely required to use sudo to start the docker daemon. I'll see if I can allocate time to set up the docker service and rerun the tests.

@shermp
Copy link

shermp commented Oct 4, 2022

I was going to recommend cross-compiling using debian multi-arch, but when I tried it, I ran into a screeching halt. The Nodesource binary distribution depends on an architecture specific version of python-minimal, and you can only have one python install at a time. Installing an arm64 version of python basically breaks dpkg :(

It might be possible to compile nodejs and node-gyp separately (and tell node-gyp to use the host python).

@acalcutt
Copy link
Collaborator Author

acalcutt commented Oct 4, 2022

The previous attempt at cross compilation i saw also had an issue with glfw, but I never tried that myself

@acalcutt
Copy link
Collaborator Author

acalcutt commented Oct 4, 2022

nodesource does have arm64 packages too, but only when installed on a arm64 platform. I am using that for my container based build.

@shermp
Copy link

shermp commented Oct 4, 2022

nodesource does have arm64 packages too, but only when installed on a arm64 platform. I am using that for my container based build.

Yeah, it was the arm64 packages causing me issues. Because it wants the arm64 version of python. Which then breaks dpkg because it removes the amd64 version of python.

@acalcutt
Copy link
Collaborator Author

acalcutt commented Oct 7, 2022

@birkskyum did you ever get to look at installing that docker service?

On a side note, I was looking a bit at what it would take to make this package build on it's own without needing binaries. I was looking at cmake-js but in my test here https://github.com/wifidb/maplibre-gl-native/tree/cmake-js it was having issues with vendor cmake files (mapbox I think). but maybe with some more testing something like this could work so you could build this on any system that had the dependencies installed.

@birkskyum
Copy link
Member

@acalcutt , unfortunately, I haven't been able to do this yet.

@acalcutt
Copy link
Collaborator Author

I still would love to get this linux-arm binary created. On the tileserver-gl side I have already updated the docker images to be compatible with arm, I am just waiting for official binaries so I can make a PR for my release workflow there.

Copy link
Member

@birkskyum birkskyum left a comment

Choose a reason for hiding this comment

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

Great job!

@acalcutt
Copy link
Collaborator Author

acalcutt commented Dec 7, 2022

@birkskyum when do you think we could merge this and try another node pre-release? I think I have most of the groundwork for a arm64 tileserver-gl already, so I would love to see this binary made.

@wipfli
Copy link
Member

wipfli commented Dec 9, 2022

I assume @birkskyum just wanted to let you merge this pull request, but I think that only works if you have write access...

Copy link
Member

@wipfli wipfli left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

@wipfli wipfli merged commit a405d7a into maplibre:main Dec 9, 2022
@acalcutt
Copy link
Collaborator Author

acalcutt commented Dec 9, 2022

Nice! glad to see this merged. When someone has a change could the "node-release" workflow be run with another prerelease version to test the release?

And no I don't have write access here right now. wouldn't mind having it but I'm fine without.

@wipfli
Copy link
Member

wipfli commented Dec 10, 2022

Granted you write access, @acalcutt. Thanks for all the good work you did on node support!

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.

None yet

4 participants