node-gyp support in alpine linux

Grigor Khachatryan
devgorilla
Published in
1 min readJul 9, 2019

Dockerize NodeJS applications using Alpine Linux with ease

When using alpine, you need to install build dependencies for some node module to be able to be built natively.

Here is an example of how you would install dependencies for packages that require node-gyp support on the alpine variant:

And Here’s a multistage build example:

Pro Tip:

As Alpine Linux uses musl, you may run into some issues with environments expecting glibc-like behavior — especially if you try to use binaries compiled with glibc. You should recompile these binaries to use musl (compiling on Alpine is probably the easiest way to do this).

If you get an error similar to error loading shared library ld-linux-x86-64.so.2, it may be that you have dependencies relying on libc – you can try to fix this by adding RUN apk add --no-cache libc6-compat or RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 to your Dockerfile.

Like to learn?

Follow me on twitter where I post all about the latest and greatest AI, DevOps, VR/AR, Technology, and Science! Connect with me on LinkedIn too!

--

--