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 ARM64 when using Heroku-24 Docker images #1268

Open
edmorley opened this issue May 29, 2024 · 1 comment · May be fixed by #1321
Open

Support ARM64 when using Heroku-24 Docker images #1268

edmorley opened this issue May 29, 2024 · 1 comment · May be fixed by #1321

Comments

@edmorley
Copy link
Member

Heroku itself currently runs on AMD64 CPUs, however, some users use our buildpacks locally on machines with ARM64 CPUs (such as M1/M2/M3 MacBooks) with the Heroku base images published to Docker Hub.

As such there have been requests to support the ARM64 architecture, e.g.:
heroku/base-images#194

Starting with Heroku-24, the base images published to Docker Hub are now multi-architecture (AMD64 + ARM64), and our preview Cloud Native Buildpacks support ARM64 when using Heroku-24.

However, until CNBs leave preview there will still be users using our classic buildpacks with our base images from Docker Hub, so it would be ideal if we could add ARM64 support to our classic buildpacks too. This will not only make the images faster to run locally, but also avoid breaking local development workflows if users update to Heroku-24 and miss the mention in the stack upgrade notes about using --platform linux/amd64 to force the architecture back to AMD64.

For example, the buildpack should support:

  1. git clone https://github.com/heroku/node-js-getting-started && cd node-js-getting-started
  2. Add a Dockerfile with the below contents.
  3. docker build --tag arm-test --platform linux/arm64 .
  4. docker run --rm -e PORT=5001 -p 5001:5001 arm-test
  5. curl localhost:5001
FROM heroku/heroku:24-build as build
ENV STACK=heroku-24
COPY --chown=heroku . /app
WORKDIR /app
# This is after the COPY line so buildpack updates are picked up.
RUN mkdir -p /tmp/buildpack /tmp/cache /tmp/env \
  && curl https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz \
    | tar -xz -C /tmp/buildpack
RUN /tmp/buildpack/bin/compile /app /tmp/cache /tmp/env

FROM heroku/heroku:24
COPY --from=build --chown=heroku /app /app
ENV HOME=/app
WORKDIR /app
CMD ["bash", "-c", "for f in .profile.d/*; do source \"${f}\"; done && npm start"]

Currently when I try the above, I get this error (which is expected, since support for ARM64 hasn't yet been added):

$ docker build --tag arm-test --platform linux/arm64 .
...
 > [build 5/5] RUN /tmp/buildpack/bin/compile /app /tmp/cache /tmp/env:                                               
0.283                                                                                                                 
0.283 -----> Creating runtime environment                                                                             
0.286                                                                                                                 
0.287        NPM_CONFIG_LOGLEVEL=error
0.289        NODE_VERBOSE=false
0.289        NODE_ENV=production
0.289        NODE_MODULES_CACHE=true
0.291        
0.291 -----> Installing binaries
0.299        engines.node (package.json):   20.x
0.299        engines.npm (package.json):    unspecified (use default)
0.299        
0.425        Resolving node version 20.x...
0.446        Downloading and installing node 20.13.1...
5.984 /tmp/buildpack/lib/binaries.sh: line 199:   309 Trace/breakpoint trap   "$@" > "$TMP_COMMAND_OUTPUT" 2>&1
5.984        rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
6.089 
6.089 -----> Build failed
6.155        
6.155        We're sorry this build is failing! You can troubleshoot common issues here:
6.155        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
6.155        
6.155        If you're stuck, please submit a ticket so we can help:
6.155        https://help.heroku.com/
6.155        
6.155        Love,
6.155        Heroku

cc @colincasey

@mlarraz
Copy link

mlarraz commented Sep 12, 2024

My PR at #1321 addresses this issue, but the buildpack still fails on ARM because it will download an AMD node binary no matter what, since the inventory file does not contain ARM builds.

I think the resolve-version and/or generate_inventory scripts needs to be updated to match the changes in this PR heroku/buildpacks-nodejs#814

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

Successfully merging a pull request may close this issue.

2 participants