1

I build my own docker images and run them on Heroku. This works just great, heres an example Docker file:

FROM node:14-alpine
WORKDIR /app
COPY ./ncc/web ./
CMD node ./index.js

The problem is I would also like to use Jemalloc for better memory management when running node. I have used this Jemalloc buildpack in the past when using normal node dynos (not docker images) and it has worked great:

https://github.com/gaffneyc/heroku-buildpack-jemalloc

If I understand correctly however buildpacks and docker images arent compatible? So this buildpack wont be available from inside my image automatically?

Is there a way to get the buildpack to run inside my image?

If not does anyone know how I might go about installing and using jemalloc in my instance?

mikeysee
  • 1,613
  • 1
  • 18
  • 31

1 Answers1

1

I think Cloud Native Buildpacks are what you're in need of. Cloud Native Buildpacks produce Docker images as output, which means you don't even need a Dockerfile.

The heroku/buildpacks:18 CNB builder image includes the heroku/nodejs buildpack. But you'll need to add the jemalloc buildpack manually. Since jemalloc is an old-style buildpack (i.e. not Cloud Naitve), you'll need to use the CNB shim. In this way you can reference the buildpack with this URL:

https://buildpack-registry.heroku.com/cnb/gaffneyc/jemalloc

All that said, and with the Pack CLI installed, you should be able to run:

$ pack build --builder heroku/buildpacks:18 --buildpack heroku/nodejs,https://buildpack-registry.heroku.com/cnb/gaffneyc/jemalloc my app
codefinger
  • 10,088
  • 7
  • 39
  • 51
  • thanks mate I really appreciate the help, I think you are on the right track, however running: ``` pack build --publish --builder heroku/buildpacks:18 --buildpack heroku/nodejs,https://buildpack-registry.heroku.com/cnb/gaffneyc/jemalloc heroku18-nodejs-jemalloc ``` Results in error: ``` ERROR: No buildpack groups passed detection. ERROR: Please check that you are running against the correct path. ERROR: failed to detect: no buildpacks participating ERROR: failed to build: executing lifecycle: failed with status code: 100 ``` – mikeysee Dec 23 '20 at 23:11
  • make sure you put the `https://` in front of the `https://buildpack-registry.heroku.com/cnb/gaffneyc/jemalloc` URL – codefinger Dec 26 '20 at 16:12
  • Does the directory you're running the command in have a `package.json`? – codefinger Dec 26 '20 at 16:12
  • I not sure. I actually found a different way to solve this issue in the end by simply adding jemalloc into my docker image: https://hub.docker.com/repository/docker/mikeysee/battletabs – mikeysee Dec 28 '20 at 00:40