heroku-buildpack-nodejs
heroku-buildpack-nodejs copied to clipboard
Fails to install node binary when running in docker on apple silicon
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:
- Download the Dockerfile.txt
- Remove the
.txt
extension - run
docker build . --platform=linux/amd64
- See error fail.log
Versions (please complete the following information):
- heroku-20
- node 14.x
- NPM or Yarn Version: [e.g.
Yarn 1.22.10
] - latest (https://github.com/heroku/heroku-buildpack-nodejs/archive/refs/tags/latest.zip)
Additional context Running heroku:20 and the buildpack in docker to create heroku-like runtime environment for local dev.
.
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)
Returning darwin-arm64
to the getPlatform()
fn didn't solve this for me. Are there any other solutions?
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 👏