gpt4 book ai didi

python - 使用 mongodb-client-encryption 的 Node Alpine 图像编译错误

转载 作者:行者123 更新时间:2023-12-05 07:02:06 25 4
gpt4 key购买 nike

我正在使用带有 node:12.18.3-alpine 图像的 Docker。我将 mongodb-client-encryption 添加到 package.json 但是当我在图像中安装包时它给了我错误。一切都适用于 node:12.18.3 图片。除了 python、g++ 和 make,我还需要安装其他东西吗?我创建了最小复制:

Package.json:

{
"name": "MONG-ENCRPT-TEST",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"mongodb-client-encryption": "^1.1.0"
}
}

这是我的 Dockerfile:

FROM node:12.18.3-alpine

WORKDIR /user/app

COPY package.json .
COPY yarn.lock .

RUN apk update && apk add python g++ make && rm -rf /var/cache/apk/*
RUN yarn

CMD echo ok

docker-compose.yml:

version: '3.8'
services:
api-test-mongo:
restart: unless-stopped
build:
context: ./
dockerfile: ./Dockerfile
command: echo ok

这是运行 docker-compose-up 后的错误:

[5/5] Building fresh packages...
error /user/app/node_modules/mongodb-client-encryption: Command failed.
Exit code: 1
Command: prebuild-install --tag-prefix node-v || node-gyp rebuild
Arguments:
Directory: /user/app/node_modules/mongodb-client-encryption
Output:
prebuild-install WARN install No prebuilt binaries found (target=12.18.3 runtime=node arch=x64 libc=musl platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.1
gyp info using node@12.18.3 | linux | x64
gyp info find Python using Python version 2.7.18 found at "/usr/bin/python"
gyp http GET https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-headers.tar.gz
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-headers.tar.gz
gyp http GET https://unofficial-builds.nodejs.org/download/release/v12.18.3/SHASUMS256.txt
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v12.18.3/SHASUMS256.txt
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args '/user/app/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/user/app/node_modules/mongodb-client-encryption/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/user/app/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.cache/node-gyp/12.18.3/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/12.18.3',
gyp info spawn args '-Dnode_gyp_dir=/user/app/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.18.3/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/user/app/node_modules/mongodb-client-encryption',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/user/app/node_modules/mongodb-client-encryption/build'
CXX(target) Release/obj.target/mongocrypt/src/mongocrypt.o
In file included from ../src/mongocrypt.cc:1:
../src/mongocrypt.h:8:10: fatal error: mongocrypt/mongocrypt.h: No such file or directory
8 | #include <mongocrypt/mongocrypt.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [mongocrypt.target.mk:113: Release/obj.target/mongocrypt/src/mongocrypt.o] Error 1
make: Leaving directory '/user/app/node_modules/mongodb-client-encryption/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/user/app/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/local/bin/node" "/user/app/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /user/app/node_modules/mongodb-client-encryption
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok

最佳答案

"mongodb-client-encryption": "1.2.1" in package.json 时,Docker 构建成功

高版本的NODEJS,尽量使用最新版本的mongodb-client-encryption

关于python - 使用 mongodb-client-encryption 的 Node Alpine 图像编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63665691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com