如何使用 CI-CD 进程将 Angular8 应用程序部署到 google 应用引擎?

How to deploy an Angular8 application to google app engine using CI-CD process?

我正在尝试使用 CI-CD 进程将我的 UI 应用程序部署到 google app engine。这对我来说是全新的。以下是我遵循的步骤:

  1. 镜像了我的 bitbucket 存储库。
  2. 创建了 cloudbuild.yamlapp.yaml 个文件。
  3. 创建了云构建触发器。

这是我的 cloudbuild.yaml 文件:

steps:
# Install npm
- name: 'node:10.10.0'
  args: ['npm', 'install']
  dir: './UI'
# Build productive file
- name: 'node:10.10.0'
  args: ['npm', 'run', 'build', '--prod']
  dir: './UI'
# Deploy UI to CP-D
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', './']
  dir: './UI'

app.yaml:

runtime: python27
threadsafe: true

handlers:
- url:  /(.*\.js)
  mime_type: text/javascript
  static_files: EPortal/
  upload: EPortal/(.*\.js)

- url:  /favicon.ico
  static_files: EPortal/favicon.ico
  upload: EPortal/assets/favicon.ico

- url:  /(.*\.(gif|png|jpg|css|js|json)(|\.map))$
  static_files: EPortal/
  upload: EPortal/(.*)(|\.map)

- url:  /(.*\.svg)
  static_files: EPortal/
  upload: EPortal/(.*\.svg)
  mime_type: image/svg+xml

- url:  /.*
  secure: always
  redirect_http_response_code: 301
  static_files: EPortal/index.html
  upload: EPortal/index\.html
  http_headers:
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Frame-Options: DENY

下面是生成的日志。出于安全原因,仅粘贴少量日志:

Step #2: Do you want to continue (Y/n)?  
Step #2: Beginning deployment of service [default]...
Step #2: ERROR: (gcloud.app.deploy) Cannot upload file [/workspace/UI/node_modules/canvas/build/Release/librsvg-2.so.2], which has size [47123185] (greater than maximum allowed size of [33554432]). Please delete the file or add to the skip_files entry in your application .yaml file and try again.
Finished Step #2
ERROR
ERROR: build step 2 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

除我的 deployment 外,一切正常。由于 size 问题未部署。如果你能帮我解决这个问题,那将是一个很大的帮助。

谢谢。

Python申请中需要node_modules吗?看起来这只是为了构建一个静态站点。在这种情况下,您可能想要忽略 node_modules

鉴于您当前的应用程序配置,它可能看起来像:

runtime: python27
threadsafe: true
skip_files:
  - node_modules/

handlers:
- url:  /(.*\.js)
  mime_type: text/javascript
  static_files: EPortal/
  upload: EPortal/(.*\.js)

- url:  /favicon.ico
  static_files: EPortal/favicon.ico
  upload: EPortal/assets/favicon.ico

- url:  /(.*\.(gif|png|jpg|css|js|json)(|\.map))$
  static_files: EPortal/
  upload: EPortal/(.*)(|\.map)

- url:  /(.*\.svg)
  static_files: EPortal/
  upload: EPortal/(.*\.svg)
  mime_type: image/svg+xml

- url:  /.*
  secure: always
  redirect_http_response_code: 301
  static_files: EPortal/index.html
  upload: EPortal/index\.html
  http_headers:
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Frame-Options: DENY