HELP: Docker Image for NodeJS App using Couchbase SDK 3.2

Hi,

So we have a nodejs micro-service using the NodeJS Couchbase SDK 3.2

We are trying to build a minimal docker image for our App using the Alpine base image but it seems the sdk needs more than what we have added to our base image.

Here is our dockerfile

FROM node:12-alpine3.13

RUN apk add --no-cache --virtual .gyp python3 make g++

WORKDIR /app

COPY package*.json ./

COPY .npmrc ./

RUN npm cache clean --force
RUN rm -rf node_modules
RUN npm install --only=production

RUN rm -rf .gyp

COPY . .

CMD [ “npm”, “start”]

We run into the following error,
Error: Error loading shared library libresolv.so.2: No such file or directory (needed by /app/node_modules/couchbase/build/Release/couchbase_impl.node)
at Object.Module._extensions…node (internal/modules/cjs/loader.js:1187:18)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.bindings [as default] (/app/node_modules/bindings/bindings.js:112:48)
at Object. (/app/node_modules/couchbase/dist/binding.js:70:35)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)

Is there any extra alpine lib we need to add ?

EDIT: This issue seems to be deeper than I thought.
Refer to this thread : alpine - Use shared library that uses glibc on AlpineLinux - Stack Overflow
So it says Alpine uses musl as a c lib and apparently couchbase needs glibc ?

Hi @SpartanX1! Unfortunately it looks like Alpine is not currently supported, in part because of the glibc issue you discovered. I suggest you take a look at the supported platforms page and pick which is best suited for you. Most of these platforms will have slim/lightweight versions that should fit your needs. Feel free to follow up with further issues or concerns!

Hey @SpartanX1 ,

Can you try to install couchbase with the --build-from-source option? This will cause the library to be built directly for alpine rather than using our prebuilds. We do actually build in our test environments for Alpine, but it seems like prebuild selection may not be working as intended. Forcing it to build from source may be a reasonable workaround for the short term.

Cheers, Brett

Hi Guys,

Installing couchbase and node-gyp separately works !

FROM node:12-alpine3.13
RUN apk add --no-cache --virtual .gyp python3 make g++
WORKDIR /app
COPY package*.json ./
COPY .npmrc ./
RUN npm cache clean --force
RUN rm -rf node_modules
RUN npm install
RUN npm install -g node-gyp
RUN npm install couchbase
RUN rm -rf .gyp
COPY . .
CMD [ “npm”, “start”]

Thanks @austin , Brett and @ejscribner

1 Like

Awesome! Glad to hear you got it working!