【问题标题】:Angular 5 - GAE flex environment deploymentAngular 5 - GAE 弹性环境部署
【发布时间】:2018-05-16 03:01:29
【问题描述】:

我们使用 angular 5 的 bitbucket 管道将代码部署到 GAE。我们最终会遇到以下异常。我们使用 CI/CD 的 bitbucket 管道

这是管道代码

    image: node:9.11.1
     pipelines:

      custom:

       default:

         - step:

           script: 

             -  npm install -g @angular/cli@latest

             - ng build --prod
             - cp app.yaml dist
             - ls dist
             - cd dist

             - curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-190.0.0-linux-x86_64.tar.gz

             - tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/

             - /tmp/google-cloud-sdk/install.sh -q

             - source /tmp/google-cloud-sdk/path.bash.inc
             - echo $GCLOUD_API_KEYFILE | base64 --decode --ignore-garbage > ./gcloud-api-key.json
             - gcloud config set project $GCLOUD_PROJECT

             - gcloud components install app-engine-java

             - gcloud auth activate-service-account --key-file gcloud-api-key.json

             - echo $GCLOUD_API_KEYFILE > /tmp/client-secret.json  

             - gcloud config set project $GCLOUD_PROJECT
             - gcloud app update --split-health-checks --project adtecy-ui 

             - gcloud app deploy app.yaml

我希望使用节点 docker 映像将 angular 5(版本 5.2.11)应用程序部署到 GAE flex 环境,但这需要非常长的时间,并且状态仍然是“进行中”(不确定通常的部署时间)

这是我的 app.yaml 文件

    env: flex
    runtime: python


    threadsafe: true

    readiness_check:

       timeout_sec: 4
       check_interval_sec: 5
       failure_threshold: 2
       success_threshold: 2
       app_start_timeout_sec: 3600

我给出了一个非常长的超时时间,因为之前的推送失败并超时

我相信 GAE 默认使用 python,因此我们没有安装 python 现在部署运行了大约 20 分钟左右,但没有让我们知道任何结果。你们能帮助我用最少的时间将我的应用程序部署到 GAE 吗?

编辑: 现在我们在运行 33 分钟后得到了结果 `21df82f90a72: 图层已经存在

    aeb4b6656589: Pushed

    latest: digest: 

sha256:c57d3178321c5f2721fc70cd00cb7862d469c74a6bf616ecfda760342c13af7e size: 3255

    DONE
    --------------------------------------------------------------------------------
    Updating service [default] (this may take several minutes)...
    .failed.
     ERROR: (gcloud.app.deploy) Operation [apps/adtecy- 
     ui/operations/9c273f87-91a3-495a-b75d-0d6c767dce97] timed out. 
     This operation may still be underway.`

【问题讨论】:

  • 您不应该像在 app.yaml 文件中那样将 nodejs 运行时与 Python 混合使用。 GAE 默认不使用 Python,它有不同语言的运行时。查看this link 中的示例。 app.yaml 在第一行应该是这样的:runtime: nodejs env: flex 先试试这个改变,然后告诉我会发生什么。

标签: angular5 gcloud bitbucket-pipelines


【解决方案1】:

您可以通过运行检查部署操作的状态

gcloud 应用操作“apps/adtecy-ui/operations/9c273f87-91a3-495a-b75d-0d6c767dce97”

【讨论】:

  • 现在由于我使用 bitbucket 管道,我将没有任何机制与控制台交互。而且“9c273f87-91a3-495a-b75d-0d6c767dce97”是上一次运行报错的操作。所以我相信我将无法添加上述命令,因为在新运行时将为该操作生成新 ID。有没有其他方法可以解决这个问题?
  • 我能够得到最终部署,并且 GAE 实例当前正在服务,但它抛出“404 - 在此服务器上找不到请求的 URL /”异常。你能告诉我你对此的看法吗?
  • 我尝试在本地模拟延迟问题,并且能够使用不同的 app.yaml 文件复制它。但是您再次指定的操作命令说健康检查没有按时完成,因此超时。您能否建议一种在 GAE 中成功访问链接的方法
【解决方案2】:

运行应用程序似乎存在问题是 nodejs 环境。所以我切换到 python27 并且能够成功部署它。但是,当我尝试使用 GAE 中提供的应用程序加载时,它会引发错误。

https://adtecy-ui.appspot.com

这是我的 app.yaml(我也做了一些修改)

    runtime: python27
    api_version: 1
    threadsafe: true



    handlers:
    # Routing for bundles to serve directly
    - url: /((?:inline|main|polyfills|styles|vendor)\.[a-z0-9]+\.bundle\.js)
      secure: always
      redirect_http_response_code: 301
      static_files: dist/\1
      upload: dist/.*

      # Routing for a prod styles.bundle.css to serve directly
      - url: /(styles\.[a-z0-9]+\.bundle\.css)
        secure: always
        redirect_http_response_code: 301
        static_files: dist/\1
        upload: dist/.*

        # Routing for typedoc, assets and favicon.ico to serve directly
        - url: /((?:assets|docs)/.*|favicon\.ico)
         secure: always
         redirect_http_response_code: 301
         static_files: dist/\1
         upload: dist/.*


         # Any other requests are routed to index.html for angular to 
         handle so we don't need hash URLs
         - url: /.*
           secure: always
           redirect_http_response_code: 301
           static_files: dist/index.html
           upload: dist/index\.html

【讨论】:

  • 错误是 404 - 在此服务器上找不到请求的 URL /。因此,如果有人可以对此有所了解,那将很有帮助,因为我正在努力使其正常工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-01
  • 1970-01-01
  • 2018-10-05
  • 1970-01-01
  • 1970-01-01
  • 2020-06-17
  • 1970-01-01
相关资源
最近更新 更多