node.js - 无法在节点上构建 node-re2:12.18.1-alpine docker 映像
问题描述
我尝试在最新的节点 12.18.1 lts alpine 上构建 node-re2,以便以后可以将二进制文件复制到生产映像中。不幸的是,它无法编译。我错过了什么?即使 ld-linux-x86-64.so.2 文件应该在包中,安装 libc6-compat 或 gcompatRUN apk add --no-cache gcompat
也无济于事。RUN apk add --no-cache libc6-compat
我的 dockerfile 是
FROM node:12.18.1-alpine as re2-builder
WORKDIR /opt
RUN apk add python make g++ \
&& npm install re2@1.15.0
构建时我得到这个:
Writing to build/Release/re2.node ...
> re2@1.15.0 verify-build /opt/node_modules/re2
> node scripts/verify-build.js
internal/modules/cjs/loader.js:1188
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /opt/node_modules/re2/build/Release/re2.node)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1188:18)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/opt/node_modules/re2/re2.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2@1.15.0 verify-build: `node scripts/verify-build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the re2@1.15.0 verify-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-06-19T21_07_53_335Z-debug.log
Building locally ...
> re2@1.15.0 rebuild /opt/node_modules/re2
> node-gyp rebuild
...
解决方案
Alpine 使用musl libc,它的共享库加载器名称ld-musl-x86_64.so.1
位于/lib
目录中。ld-linux-x86-64.so.2
是在 Ubuntu 或其他标准发行版中使用的 glibc 共享库加载器。有兼容层包名称libc6-compat
尝试添加。
apk add libc6-compat
或尝试符号链接原始文件
ln -s /lib/ld-musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
那应该解决。
Error loading shared library ld-linux-x86-64.so.2: No such file or directory
推荐阅读
- swift - 如何将多个视图控制器合并到一个滚动视图中。
- apache-spark - 在包含保留字符的 Spark 中解析 JSON
- angularjs - 如何做 ng-model 选择颜色的正确方法?
- github - Terraform 错误:权限映射中应有至少一项权限
- sharepoint-2013 - 在快速启动中创建缩进菜单,可以看到基于permission-sharepoint 2013
- azure - Azure ARM 部署 DNS 条目
- magento2 - 当用户将商店从一个商店切换到另一个 Magento 2 时,迷你购物车不刷新
- ipython - 将 (1,103,10) 重塑为 (103,10) 数组
- javascript - 滚动文档,使单击的元素出现在页面顶部
- java - 如何让nestedscrollview 可以滚动或不滚动?