无法在 Alpine Linux 上运行 node-gdal:"__printf_chk: symbol not found"



我正在尝试使用node-gdal(gdal的node.js绑定)为项目添加gitlab ci。由于性能原因,CI配置基于Alpine Linux Docker图像,但我无法使其正常工作。GitLab CI作业在运行Node.js脚本时失败,该脚本需要node-gdal,并具有以下错误:

internal/modules/cjs/loader.js:718
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^
Error: Error relocating /builds/project-0/node_modules/gdal/lib/binding/node-v64-linux-x64/gdal.node: __printf_chk: symbol not found
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/builds/project-0/node_modules/gdal/lib/gdal.js:12:29)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

试图为高山安装GLIBC,但仍然没有运气。

.gitlab-ci.yml

image: node:lts-alpine
stages:
  - test
test:
  stage: test
  before_script:
    - apk add --no-cache bash ca-certificates wget
    - wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
    - wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk
    - apk add glibc-2.29-r0.apk
  script:
    - yarn
    - node index.js

这是重现问题的仓库,这是失败的作业的链接。

是否有任何解决方案可以使用高山上的库?

多亏了这一点,这与此相关的问题和答案,我能够在Alpine上使用以下CI配置(链接到传递的作业)构建node-gdal与共享GDAL库链接:

.gitlab-ci.yml

image: node:lts-alpine
stages:
  - test
test:
  stage: test
  before_script:
    - apk add --no-cache bash make gcc g++ python linux-headers udev --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing --repository http://dl-cdn.alpinelinux.org/alpine/edge/main gdal gdal-dev
  script:
    - npm install gdal --build-from-source --shared_gdal
    - node index.js

最新更新