【问题标题】:Firebase deploy functions with Sharp library fails in Google Cloud Build使用 Sharp 库的 Firebase 部署功能在 Google Cloud Build 中失败
【发布时间】:2019-11-02 15:47:16
【问题描述】:

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

除了下面的错误之外没有给出进一步的解释。我对代码的部分进行了注释,以意识到“const sharp = require('sharp')”是导致构建失败的一个命令。

但是没有明显的原因导致“firebase deploy”因“require('sharp')”而失败,我必须设法解决这个问题。

Google Cloud Build 中的 Firebase 部署输出

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"]

有什么想法吗?

【问题讨论】:

  • 我已经阅读了这个问题。我的错误没有那么冗长,而且只发生在 Cloud Build 上。我也知道 Node 版本不是问题,因为我在 Bitbucket Pipelines 上使用了相同的 docker 映像。

标签: node.js firebase google-cloud-functions google-cloud-build sharp


【解决方案1】:

这次我真的明白了。

我运行 npm ci 来构建云功能,然后通过 firebase deploy 将它们部署到云中。问题是,正如您在 gcr.io/$PROJECT_ID/firebase 上面的 docker 文件中看到的那样,映像是使用节点 10.15.3 构建的,而 gcr.io/cloud-builders/npm 使用的是节点 8。唯一的 npm 包是Sharp 够挑剔,所以它没能建成。

最糟糕的是,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 中指定的节点引擎的版本相匹配。

【讨论】:

  • setting node: "10" in package json as described here firebase.google.com/docs/functions/… and 真正使用节点 10 作品
  • “解决方案”部分提到的数据在哪里设置?
  • 这是云构建yaml文件
  • 云构建yaml文件在哪里?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-26
  • 2021-12-29
  • 2020-05-23
  • 1970-01-01
  • 2020-11-13
  • 2020-11-20
  • 2021-03-29
相关资源
最近更新 更多