简体   繁体   English

Docker Nodejs 和 Couchbase 图像 SDK

[英]Docker image for Nodejs and Couchbase SDK

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.所以我们有一个使用 NodeJS Couchbase 的 nodejs 微服务SDK 3.2 我们正在尝试使用 Alpine 基础图像为我们的应用程序构建一个最小的 docker 图像,但似乎 sdk 需要的不仅仅是我们添加到基础图像中的图像。

Here is our dockerfile这是我们的 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: Use shared library that uses glibc on AlpineLinux参考这个线程: Use shared library that uses glibc on AlpineLinux

So it says Alpine uses musl as a c lib and apparently couchbase needs glibc?所以它说 Alpine 使用 musl 作为 c 库,显然 couchbase 需要 glibc?

EDIT 2: This now works.编辑 2:现在可以使用了。

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”]

Answered on the Couchbase forums: https://forums.couchbase.com/t/help-docker-image-for-nodejs-app-using-couchbase-sdk-3-2/33267在 Couchbase 论坛上回答: https://forums.couchbase.com/t/help-docker-image-for-nodejs-app-using-couchbase-sdk-3-2/33267

In short, Alpine is not officially supported.简而言之,官方不支持 Alpine。 You can read more information on platform compatibility in the documentation .您可以在文档中阅读有关平台兼容性的更多信息。 There you can find a supported distro that works well for your needs.在那里,您可以找到适合您需求的受支持发行版。

As was shared on the forums, the option --build-with-source will avoid using prebuilds, which may provide an adequate workaround for building on Alpine but its important to note that this is not the same as an officially supported platform.正如在论坛上分享的那样,选项--build-with-source将避免使用预构建,这可能为在 Alpine 上构建提供足够的解决方法,但重要的是要注意这与官方支持的平台不同。

Feel free to follow up with any additional questions or concerns!如有任何其他问题或疑虑,请随时跟进!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM