当前位置: 首页 > 知识库问答 >
问题:

尝试用云构建(gcp)部署时出现未找到的URL

戈嘉慕
2023-03-14

应用-角度

我试图在GCP中自动化我的angular应用程序的部署过程。当我从cloud shell手动部署时,工作很好,但当我尝试使用CloudBuild.yaml构建-部署时,cloud build会触发,它表示部署成功。当我点击URL时,它说404没有找到。

gsutil rsync -r gs://v2-appname.appspot.com ./deploytest
cd deploytest
gcloud app deploy

我不太熟悉云构建。

问题可能出现在下面给出的cloudbuild.yaml文件中。

steps:

      # Install node packages
      - name: "gcr.io/cloud-builders/npm:latest"
        args: ["install"]
    
      # Build production package
      - name: "gcr.io/cloud-builders/npm"
        args: ["build", "--configuration=staging"]
    
      # Deploy to google cloud app engine
      - name: "gcr.io/cloud-builders/gcloud"
        args: ["app", "deploy", "app.yaml"]

我所理解的是,当我们手动部署时,我们构建并上传文件到存储中的“dist”文件夹。然后我们同步目录进行部署,然后使用gcloud app deploy进行部署。

EA_Website ->
         src/
         cloudbuild.yaml
         app.yaml
         angular.json
         package.json 
runtime: python27
threadsafe: yes
api_version: 1

# Google App Engine's cache default expiration time is 10 minutes. It's suitable for most Production
# scenarios, but a shorter TTL may be desired for Development and QA, as it allows us to see a fresh
# code in action just a minute after the deployment.
default_expiration: 60s

handlers:

# To enhance security, all http requests are redirected to their equivalent https addresses (secure: always).

# Assets are retrieved directly from their parent folder.
- url: /assets
  static_dir: dist/projectname/assets
  secure: always

# Static files located in the root folder are retrieved directly from there, but their suffixes need to be
# mapped individually in order to avoid them from being hit by the most general (catch-all) rule.
- url: /(.*\.css)
  static_files: dist/projectname/\1
  upload: dist/projectname/(.*\.css)
  secure: always

- url: /(.*\.html)
  static_files: dist/projectname/\1
  upload: dist/projectname/(.*\.html)
  secure: always

- url: /(.*\.ico)
  static_files: dist/projectname/\1
  upload: dist/projectname/(.*\.ico)
  secure: always

- url: /(.*\.js)
  static_files: dist/projectname/\1
  upload: dist/projectname/(.*\.js)
  secure: always

- url: /(.*\.txt)
  static_files: dist/projectname/\1
  upload: dist/projectname/(.*\.txt)
  secure: always

# Site root.
- url: /
  static_files: dist/projectname/index.html
  upload: dist/projectname/index.html
  secure: always

# Catch-all rule, responsible from handling Angular application routes (deeplinks).
- url: /.*
  static_files: dist/projectname/index.html
  upload: dist/projectname/index.html
  secure: always

skip_files:
- ^(?!dist)
steps:

- name: "gcr.io/cloud-builders/npm:node-12.18.3"
  entrypoint: npm
  args: ['install']

- name: gcr.io/cloud-builders/npm
  args: [run, build, --prod]

- name: gcr.io/cloud-builders/gcloud
  args: [ app, deploy, --version=$SHORT_SHA ]


ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (83)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.12.0

共有1个答案

夹谷辰沛
2023-03-14
  args: ["build", "--prod"]
  args: ["run", "build", "--prod"]
  args: [run, build, --prod]
steps:

- name: gcr.io/cloud-builders/npm
  args: [ install ]

- name: gcr.io/cloud-builders/npm
  args: [ run, build, --prod]

- name: gcr.io/cloud-builders/gcloud
  args: [ app, deploy, --version=$SHORT_SHA ]
  
runtime: python27
threadsafe: yes
api_version: 1

# Google App Engine's cache default expiration time is 10 minutes. It's suitable for most Production
# scenarios, but a shorter TTL may be desired for Development and QA, as it allows us to see a fresh
# code in action just a minute after the deployment.
default_expiration: 60s

handlers:
    # Static files located in the root folder are retrieved directly from there, but their suffixes need to be
    # mapped individually in order to avoid them from being hit by the most general (catch-all) rule.
    - url: /(.*\.css)
      static_files: dist/projectname/\1
      upload: dist/projectname/(.*\.css)
      secure: always
    
    - url: /(.*\.html)
      static_files: dist/projectname/\1
      upload: dist/projectname/(.*\.html)
      secure: always
    
    - url: /(.*\.ico)
      static_files: dist/projectname/\1
      upload: dist/projectname/(.*\.ico)
      secure: always
    
    - url: /(.*\.js)
      static_files: dist/projectname/\1
      upload: dist/projectname/(.*\.js)
      secure: always
    
    - url: /(.*\.txt)
      static_files: dist/projectname/\1
      upload: dist/projectname/(.*\.txt)
      secure: always
    
    # Site root.
    - url: /
      static_files: dist/projectname/index.html
      upload: dist/projectname/index.html
      secure: always
    
    # Catch-all rule, responsible from handling Angular application routes (deeplinks).
    - url: /.*
      static_files: dist/projectname/index.html
      upload: dist/projectname/index.html
      secure: always
    
    skip_files:
    - ^(?!dist)

这是由于缓存造成的,所以您应该重新安装/update-modules。错误:找不到模块'@angull/compiler-cli,如果没有任何工作,尝试创建一个新的分支并从那里触发它(只需点击并尝试)。

 类似资料:
  • 您好,我是java开发的新手,我正在尝试修改一个同事开发的应用程序,但是当我试图部署它时,我得到了这个错误: servlet.ServletException:org.apache.ibatis.exceptions.PersistenceException: resource database.properties org.glassfish.jersey.servlet.webcomponen

  • 问题内容: 我收到一个错误,指示缺少in 。这是我的网络服务代码: 这是我的: 添加应用程序类无效: 我仍然收到此错误: UPDATE2: 现在我从浏览器执行GET请求时收到此错误 问题答案: 用(或其他字符串)注释您的班级。

  • 问题内容: 我正在尝试使用PyInstaller 1.5编译PyQt程序。当我使用– onedir(默认设置)时,以下两个程序对我来说都工作正常,但这会创建相当大的程序。我想使用– onefile选项,但是在运行创建的onefile应用程序时,出现错误消息: 这两个都发生此错误: 和这个: 有人有什么想法吗? 问题答案: 1,Pyinstaller不会创建比–onedir小的–onefile。运行

  • 当我在git中切换分支并使用安装包时,我的本地AEM实例突然停止工作。 生成失败,请求执行 我的错误日志显示以下错误:

  • 我遵循了Head First Servlets中一个非常简单的例子。 我在浏览器地址栏输入localhost:8080,显示的是Tomcat的主页,服务器好像没问题。然后我创建了一个名为< code>Ch1Servlet的servlet。它看起来是这样的: 接下来,需要一个web.xml的配置文件。所以是这样的: 在编译了Ch1Servlet.java之后,我得到了一个类文件,它被放在WEB-IN

  • 我在将我的功能部署到Google Cloud时遇到问题: Firebase CLI中的显示方式和消息: Firebase控制台上的显示方式和消息: