如何在 Google App Engine 上部署 Vue.js 应用程序?

Say*_*kar 5 google-app-engine vue.js

我创建了一个简单的 Vue.js 应用程序。然后我使用在项目结构中npm run build创建dist文件夹的命令 为生产创建了一个构建 。

然后我使用gcloud app deploy命令将它部署到 Google App Engine,但随后部署停止并给出错误:

ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: This deployment has too many files. New versions are limited to 10000 files for this app.

有人可以告诉我将 Vue.js 应用程序部署到 Google App Engine 的正确方法是什么吗?

hig*_*ian 5

您是否尝试过使用 Cloud Build 将 Vue.js 应用程序部署到 Google App Engine?我以这种方式部署任何 Vue.js 应用程序都没有问题。尝试按照本教程获取完整说明。

基本上,在通过 Cloud Build 将 Vue.js 应用程序部署到 Google App Engine 时,您必须在项目根目录中包含以下两个文件:

  1. 应用程序.yaml

    runtime: nodejs10
    handlers:
      # Serve all static files with urls ending with a file extension
    - url: /(.*\..+)$ 
      static_files: dist/\1
      upload: dist/(.*\..+)$
      # catch all handler to index.html
    - url: /.*
      static_files: dist/index.html
      upload: dist/index.html
    
    Run Code Online (Sandbox Code Playgroud)

  1. 云构建.yaml

    steps:
    - name: node:10.15.1
      entrypoint: npm
      args: ["install"]
    - name: node:10.15.1
      entrypoint: npm
      args: ["run", "build"]
    - name: "gcr.io/cloud-builders/gcloud"
      args: ["app", "deploy"]
    timeout: "1600s"
    
    Run Code Online (Sandbox Code Playgroud)

如果您不使用云构建,您可以只使用上面的 app.yaml 并参考 cloudbuild.yaml 中隐含的步骤,这意味着:

  1. npm install
  2. npm run build
  3. gcloud app deploy


小智 0

我发现一些 Google Cloud Platform 文档可能对您的问题有所帮助,在部署部分下的此链接中,它表明对于每个部署,每个版本只能上传 10,000 个文件,并且每个文件的最大大小限制为 32 MB。您遇到了这两个问题之一,我建议在您的应用程序上检查这一问题并尝试再次部署它。