heroku / heroku-buildpack-nodejs

Heroku's buildpack for Node.js applications.
https://devcenter.heroku.com/articles/buildpacks
MIT License
1.31k stars 2.63k forks source link

Fails to install node binary when running in docker on apple silicon #964

Open mmmmmrob opened 2 years ago

mmmmmrob commented 2 years ago

Describe the bug The buildpack fails while attempting to install node when running in docker on apple silicon.

The expected behaviour is that the binaries install correctly.

To Reproduce Steps to reproduce the behavior: On an apple silicon machine with docker desktop installed:

  1. Download the Dockerfile.txt
  2. Remove the .txt extension
  3. run docker build . --platform=linux/amd64
  4. See error fail.log

Versions (please complete the following information):

Additional context Running heroku:20 and the buildpack in docker to create heroku-like runtime environment for local dev.

.

joshwlewis commented 2 years ago

Yeah, it looks like we'll try to download the x64 binaries.

We really only support darwin so that we can test this buildpack locally. Nobody on the team has an M1 yet, so this isn't a big priority, though I'd entertain a PR.

It looks like the bug could be fixed by changing the architecture calculation here:

https://github.com/heroku/heroku-buildpack-nodejs/blob/39e4b172dab00c79bca77393d444a1d74f4c63d4/cmd/resolve-version/main.go#L142-L147

(It should return darwin-arm64 for M1 macs)

jaygould commented 2 years ago

Returning darwin-arm64 to the getPlatform() fn didn't solve this for me. Are there any other solutions?

abarke commented 1 year ago

This would be really awesome to support multiple platforms. In our use cases specifically M1 and AWS Graviton architectures.

We use heroku buildpacks and can now deploy to AWS Graviton processors. If the buildpack was able to detect the platform and binary to install that would be incredible 😃

Or perhaps the simplest approach for now would be to set an environment variable like NODE_PLATFORM=linux-arm64 that would pull the node distribution for ARM v8 🚀

NODE_PLATFORM would then default to the existing platform binary. This would ensure backwards compatability.

Would this work? Any thoughts? @jmorrell @edmorley @joshwlewis 🤔

For those engineers who support Sustainable Engineering 🌞 and Green Software 🌳 this would be a big deal as this would allow engineers to deploy the same code on ARM, while boosting application performance, using less energy and reducing costs. A win-win for all 👏