无法 运行 Alpine Linux 上的 node-gdal:“__printf_chk:找不到符号”

Unable to run node-gdal on Alpine Linux: "__printf_chk: symbol not found"

我正在尝试使用 node-gdal (Node.js bindings for GDAL) 为我的项目添加 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 for Alpine 但仍然没有成功。

.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

这是一个repo reproducing the issue and this is a link to failed job

是否有任何解决方案可以在 Alpine 上使用该库?

感谢 and related questions and answers, I was able to build node-gdal linking against shared GDAL library on Alpine with the following CI configuration (link to passed job):

.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