node.js - 基于Firebase功能的云通用 Angular 超时

标签 node.js angular docker google-cloud-platform google-cloud-build

我在firebase上部署了Angular Universal项目,并使用firebase函数为服务器端提供服务,也使用云构建触发了构建,尽管有时它只是一直重试,但它只是停留在服务器构建命令中以提供 Angular 通用性的问题,在本地工作,但在云上有时无法通过其他时间
云构建YAML

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'build', '-t' , 'gcr.io/$PROJECT_ID/firebase' , './dockerfiles/firebase']
- name: 'gcr.io/$PROJECT_ID/firebase'
  args: [ 'use', '$_PROJECT_NAME','--token', '${_FIREBASE_TOKEN}']
- name: 'node:12.18.3'
  entrypoint: npm
  args: ['install']
- name: 'node:12.18.3'
  entrypoint: npm
  args: ['install','--prefix','functions']
- name: 'node:12.18.3'
  entrypoint: npm
  args: ['link']
- name: 'node:12.18.3'
  entrypoint: npm
  dir:  'functions'
  args: ['install','-g', 'firebase-tools@latest']
- name: 'node:12.18.3'
  entrypoint: npm
  args: ['run-script','stage-browser']
- name: 'node:12.18.3'
  entrypoint: npm
  args: ['run-script','--debug','stage-server']
- name: 'node:12.18.3'
  entrypoint: npm
  dir:  'functions'
  args: ['run-script','copyAndRename']
- name: 'gcr.io/$PROJECT_ID/firebase'
  args: [ 'deploy','--debug', '--token', '${_FIREBASE_TOKEN}']
timeout: 2000s
Firebase Docker文件
FROM node:carbon

RUN npm install -g firebase-tools@latest

ENTRYPOINT ["/usr/local/bin/firebase"] 
构建日志,它停留在这里的时间太长了,无法在此处添加
https://justpaste.it/30aoi
运行脚本命令
    "stage-browser": "node --max_old_space_size=16384 ./node_modules/@angular/cli/bin/ng build --prod --configuration=stage --aot --vendor-chunk --common-chunk --delete-output-path",
    "stage-server": "node --max_old_space_size=16384 ./node_modules/@angular/cli/bin/ng run sf-mini:server:stage",
    "copyAndRename": "node cp-angular.js",

最佳答案

根据错误消息,这可能是由于云构建在VM中创建的执行步骤的权限所致。
为了避免出现这些权限问题,您可以做的是使用sudo调用命令
当使用sudo时,它会像这样:

- name: 'gcr.io/cloud-builders/docker'
  args: [ 'build', '-t' , 'gcr.io/$PROJECT_ID/firebase' , './dockerfiles/firebase']
- name: 'gcr.io/$PROJECT_ID/firebase'
  args: [ 'use', '$_PROJECT_NAME','--token', '${_FIREBASE_TOKEN}']
- name: 'node:12.18.3'
  entrypoint: bash
  args: ['sudo','npm','install']
- name: 'node:12.18.3'
  entrypoint: bash
  args: ['sudo','npm','install','--prefix','functions']
- name: 'node:12.18.3'
  entrypoint: bash
  args: ['sudo','npm','link']
- name: 'node:12.18.3'
  entrypoint: bash
  dir:  'functions'
  args: ['sudo','npm','install','-g', 'firebase-tools@latest']
- name: 'node:12.18.3'
  entrypoint: bash
  args: ['sudo','npm','run-script','stage-browser']
- name: 'node:12.18.3'
  entrypoint: bash
  args: ['sudo','npm','run-script','--debug','stage-server']
- name: 'node:12.18.3'
  entrypoint: bash
  dir:  'functions'
  args: ['sudo','npm','run-script','copyAndRename']
- name: 'gcr.io/$PROJECT_ID/firebase'
  args: [ 'deploy','--debug', '--token', '${_FIREBASE_TOKEN}']
timeout: 2000s

关于node.js - 基于Firebase功能的云通用 Angular 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64163117/

相关文章:

Angular2 生成器函数

docker - 尝试在OSX上部署bna文件时,Fabric Composer快速启动失败

docker - 连接docker容器

node.js - 建立在不同端口上运行的 Node.js 服务器和 ASP.NET MVC 3 客户端

javascript - 分配给另一个变量后数据发生变化

node.js - 如何将 chrome-aws-lambda 模块与 AWS lambda 函数一起使用?

javascript - Angular 7 项目无法导入 node-vibrant

javascript - Angular 6 中的 CanDeactivate 无法正常工作

java - 在本地开发中使用 Docker

node.js - NodeJS ZeroMQ,发送没有回调?