本文介绍了带有Sharp库的Firebase部署功能在Google Cloud Build中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

从Bitbucket Pipelines迁移到Google Cloud Build后,Firebase部署失败.该设置已在Bitbucket管道和本地成功部署.

After migrating to Google Cloud Build from Bitbucket Pipelines the Firebase deployment is failing. The setup was deploying successfully both on Bitbucket Pipelines and locally.

除了下面的错误外,没有给出其他解释.我注释了部分代码,以意识到"const sharp = require('sharp')"是使构建失败的一个命令.

No further explanation is given other than error below. I have comment parts of the code to to realize that "const sharp = require('sharp')" was one command that was making the build to fail.

但是没有明显的原因导致"firebase部署"失败并显示为"require('sharp')",我必须设法解决这一问题.

But there is no apparent reason why "firebase deploy" fails with "require('sharp')" and I have to way to tackle this.

Firebase在Google Cloud Build中部署输出

Firebase deploy output in 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

Dockerfile

FROM cypress/base:10.15.3

#CMD ["node"]

RUN npm install -g firebase-tools@^7.0.0
ENTRYPOINT ["/usr/local/bin/firebase"]

有什么想法吗?

推荐答案

这一次我真的知道了.

I figure it out for real this time.

我运行npm ci来构建云功能,然后将它们部署在Firebase上以将它们部署到云中.问题是,正如您在上面的docker文件中看到的那样,gcr.io/$ PROJECT_ID/firebase映像是使用节点10.15.3构建的,而gcr.io/cloud-builders/npm使用的是节点8.夏普足够挑剔,因此无法建立.

I ran npm ci to build the cloud functions and them firebase deploy to deploy them to the cloud. The problem was that as you see in the docker file above gcr.io/$PROJECT_ID/firebase image was build with node 10.15.3 while the gcr.io/cloud-builders/npm was using node 8. The only npm packages that was picky enough was Sharp and so it failed to build.

最糟糕的是,firebase对此非常保密,除了纯粹的猜测之外,我没有其他解决方法.

Worst of all is that firebase was very secretive about this and I have no lead to tackle over than pure speculation.

- 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中指定的节点引擎的版本匹配.

And this should match the version of the node engine specified in cloud functions package.json.

这篇关于带有Sharp库的Firebase部署功能在Google Cloud Build中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:16