从 Bitbucket Pipelines 迁移到 Google Cloud Build 后,Firebase 部署失败。该设置在 Bitbucket Pipelines 和本地都成功部署。
除了下面的错误之外,没有给出进一步的解释。我对代码的某些部分进行了注释,以认识到“const Sharp = require('sharp')”是导致构建失败的一个命令。
但没有明显的原因表明“firebase部署”因“require('sharp')”而失败,我必须想办法解决这个问题。
Firebase 在 Google Cloud Build 中部署输出
Step #5: === Deploying to 'werkout-staging-b1483'...
Step #5:
Step #5: i deploying functions
Step #5: ✔ functions: Finished running predeploy script.
Step #5: i functions: ensuring necessary APIs are enabled...
Step #5: ✔ functions: all necessary APIs are enabled
Step #5: i functions: preparing functions/cloud_functions directory for uploading...
Step #5:
Step #5: Error: There was an unknown problem while trying to parse function triggers. Please ensure you are using Node.js v6 or greater.
Finished Step #5
ERROR
ERROR: build step 5 "gcr.io/werkout-staging-b1483/firebase" failed: exit status 2
Dockerfile
FROM cypress/base:10.15.3
#CMD ["node"]
RUN npm install -g firebase-tools@^7.0.0
ENTRYPOINT ["/usr/local/bin/firebase"]
有任何想法吗?
这次我算是真正明白了。
我运行 npm ci 来构建云功能,然后运行 firebase deploy 将它们部署到云中。问题是,正如您在上面的 docker 文件中看到的那样,gcr.io/$PROJECT_ID/firebase 映像是使用节点 10.15.3 构建的,而 gcr.io/cloud-builders/npm 使用节点 8。夏普过于挑剔,因此未能建造。
最糟糕的是,firebase 对此非常保密,除了纯粹的猜测之外,我没有任何线索可以解决。
- name: 'gcr.io/cloud-builders/npm'
args: [ 'run', 'build' ]
- name: 'gcr.io/$PROJECT_ID/firebase'
args: [ 'firebase', 'deploy' ]
解决方案:
- name: 'gcr.io/cloud-builders/npm:node-10.10.0'
args: [ 'run', 'build' ]
- name: 'gcr.io/$PROJECT_ID/firebase'
args: [ 'firebase', 'deploy' ]
并且这应该与云函数package.json中指定的节点引擎版本匹配。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)