如何将Docusaurus网站部署到Google App Engine?



我使用docusaurus build(或npm run build)构建了一个生产就绪的Docusaurus网站。我如何将其部署到谷歌应用引擎作为一个静态网站?

在项目根目录下创建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/1
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/1/index.html
upload: build/(.*)
# anything else (e.g. /docs)
- url: /(.*)
static_files: build/1/index.html
upload: build/(.*)

然后创建一个.gcloudignore文件:

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

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

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

最新更新