【问题标题】:How to deploy a Docusaurus website to Google App Engine?如何将 Docusaurus 网站部署到 Google App Engine?
【发布时间】:2022-12-14 04:20:24
【问题描述】:

我使用docusaurus build(或npm run build)构建了一个生产就绪的 Docusaurus 网站。如何将其作为静态网站部署到 Google App Engine?我在 app.yaml 中放了什么?

【问题讨论】:

    标签: google-app-engine google-cloud-platform docusaurus


    【解决方案1】:

    在您的项目根文件夹中,创建一个包含以下内容的 app.yaml 文件:

    # runtime could be anything, it won't create any instances as everything is static
    runtime: python38 
    
    handlers:
      # static files with a URL ending with a file extension
      # (e.g. favicon.ico, manifest.json, jylade.png)
      - url: /(.*..+)$
        static_files: build/
        upload: build/(.*..+)$
    
      # index page
      - url: /
        static_files: build/index.html
        upload: build/index.html
    
      # anything that ends with a slash (e.g. /docs/)
      - url: /(.*)/$
        static_files: build//index.html
        upload: build/(.*)
    
      # anything else (e.g. /docs)
      - url: /(.*)
        static_files: build//index.html
        upload: build/(.*)
    
    

    然后,创建一个.gcloudignore 文件:

    # ignore everything
    /[!.]*
    /.?*
    
    # except for the build folder
    !/build/**
    

    最后,运行以下命令部署站点:

    gcloud app deploy app.yaml --project <YOUR GCP PROJECT>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 2015-02-19
      • 2013-02-07
      • 2017-09-29
      相关资源
      最近更新 更多