Skip to content

Deploy to Google App Engine

Masanori Ohgita edited this page Apr 26, 2022 · 13 revisions

Deploy to Google App Engine (GAE)

Overview

Deployed example: https://angular-nest-mugifly.uc.r.appspot.com/

This template application can be deployed with either of the following methods:

  • Node.js Runtime for Standard Environment (without Docker):
    • Pros.
      • Easy to deploy in a short build time.
      • If some conditions, you can use the free tier.
  • Flexible Environment (with Docker):
    • Pros.
      • You can install various dependent packages and native modules, using the apt command and other methods.

Node.js Runtime for Standard Environment (without Docker)

https://cloud.google.com/appengine/docs/standard/nodejs

Firstly, create your project on Google Cloud Platform, and please remember your Project ID.

Then, enable Cloud Build API and Billing on console: https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com?project=%YOUR_PROJECT_ID%

NOTE: The following settings are set to fit in the free tier, but you need to enable the Billing on your project. Also, it may not be free depending on the state of your project. In any case, I don't any guaranteed.

Then, please make the following 2 files to your project directory.

app.yaml:

runtime: nodejs16

instance_class: F1

handlers:
- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

.gcloudignore:

.gcloudignore

.git
.gitignore

# Node.js dependencies:
node_modules/

# Build files
client/dist/
client/src/.api-client/
server/dist/

Then, execute the following command on your project directory. By execute this command, gcp-build script will be added to package.json.

$ npm set-script gcp-build "npm run build"

After that, execute the following commands. (If you haven't already installed the gcloud command, install it from https://cloud.google.com/sdk/docs/install)

$ gcloud app deploy --project=YOUR_PROJECT_ID --stop-previous-version

Flexible Environment (with Docker)

#TODO