I built a production-ready Docusaurus website using docusaurus build
(or npm run build
). How can I deploy it to Google App Engine as a static website?
In your project root folder, create an app.yaml
file with the following contents:
# 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/(.*)
Then, create a .gcloudignore
file:
# ignore everything
/[!.]*
/.?*
# except for the build folder
!/build/**
Last, run the following command to deploy the site:
gcloud app deploy app.yaml --project <YOUR GCP PROJECT>