[尝试构建有角度+ firebase项目的产品时,它总是超时。我看到它快要完成了,但是构建angular应用产品版本的步骤已经占用了8分钟以上的时间。在本地构建时,只需50秒钟。
这些是我在cloudbuild.yaml中使用的步骤:
steps:
##########
# FUNCTIONS
##########
# Install
- name: 'gcr.io/cloud-builders/npm:node-10.10.0'
args: ['install']
dir: 'functions'
##########
# HOSTING
##########
# Install
- name: 'gcr.io/cloud-builders/npm:node-10.10.0'
args: ['install']
dir: 'hosting'
# Build
- name: 'gcr.io/cloud-builders/npm:node-10.10.0'
args: ['run', 'build', '--', '--prod=$_IS_PRODUCTION']
dir: 'hosting'
env:
- some environment variables here containing api keys etc...
##########
# DEPLOY
##########
- name: 'gcr.io/$PROJECT_ID/firebase'
args: ['deploy', '-P', '$_BUILD_LINE']
非生产版本运行正常,总共仅花费4分钟(所有步骤)。
关于为什么角度产品生成的云构建需要这么长时间以及如何减少它的任何想法?
我对此进行了调查,并在这里复制了您的问题,这是我的分析:
我建议以这种方式将“timeout” option添加到构建步骤:
# Build
- name: 'gcr.io/cloud-builders/npm:node-10.10.0'
args: ['run', 'build', '--', '--prod=$_IS_PRODUCTION']
timeout: 900s
dir: 'hosting'
env:
- some environment variables here containing api keys etc…
我把它放在这里900秒,这是15分钟,您可以更改它以满足您的需求。
无论如何,都需要考虑一些best practices:构建是否花费了很多时间: