gpt4 book ai didi

node.js - Docker Build 在 GCP Cloud Build 中失败 - 但在 localhost 中成功

转载 作者:太空宇宙 更新时间:2023-11-04 01:24:25 25 4
gpt4 key购买 nike

以下 Dockerfile 在 GCP Cloud Build 中的 npm install --product 中失败

FROM node:10.15.3-slim 

RUN sh -c 'apt-get update && apt-get install -y build-essential && apt-get install -y python'

COPY src /home/$user/
WORKDIR /home/$user

RUN npm install --production

CMD [ "npm", "start" ]

这是package.json

{
"name": "generic-cloud-node-sql",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
},
"dependencies": {
"@google-cloud/bigquery": "^4.0.0",
"@google-cloud/storage": "^2.5.0",
"body-parser": "*",
"cron": "^1.7.1",
"dateformat": "^3.0.2",
"express": "*",
"form-data": "*",
"multer": "^1.4.1",
"njwt": "*",
"promise-mysql": "^3.3.1",
"request": "^2.88.0",
"request-ip": "^2.1.3",
"throw.js": "*",
"bcrypt": "^3.0.6",
"winston": "*",
"winston-gke": "*"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0",
"chai-http": "*"
}
}

尝试安装带有消息的 bcrypt 时失败

Step #1: > bcrypt@3.0.6 install /home/node_modules/bcrypt
Step #1: > node-pre-gyp install --fallback-to-build
Step #1:
Step #1: node-pre-gyp WARN Using request for node-pre-gyp https download
Step #1: node-pre-gyp ERR! Completion callback never invoked!
Step #1: node-pre-gyp ERR! System Linux 4.15.0-1044-gcp
Step #1: node-pre-gyp ERR! command "/usr/local/bin/node" "/home/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
Step #1: node-pre-gyp ERR! cwd /home/node_modules/bcrypt
Step #1: node-pre-gyp ERR! node -v v10.15.3
Step #1: node-pre-gyp ERR! node-pre-gyp -v v0.12.0
Step #1: node-pre-gyp ERR! This is a bug in `node-pre-gyp`.
Step #1: node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:

但是当我在本地运行 docker build 时,上述 Dockerfile 和 package.json 可以成功运行。

  • 没有将任何node_modules复制到docker镜像
  • 没有将 package_lock.json 复制到 Docker 镜像
  • 在没有更改任何相关文件(Dockerfile、package.json 等)的情况下,构建过程开始失败

可能是什么问题?

最佳答案

这看起来更像是 node-pre-gyp 的问题,而不是 Cloud Build 的问题。我发现this GitHub 上与您遇到的问题相匹配的问题。这绝对值得一看。

关于node.js - Docker Build 在 GCP Cloud Build 中失败 - 但在 localhost 中成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58085604/

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