以下Dockerfile在GCP Cloud Build中的npm install --production
处失败
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成功运行了。
可能是什么问题?