Deploy a basic NodeJS application using Google’s App Engine

Dennis Pintilie Alexandru
3 min readAug 24, 2020

--

What is App Engine?

Google App Engine (often referred to as GAE or simply App Engine) is a Platform as a Service (PaaS) and cloud computing platform for developing and hosting web applications in Google-managed data centers. Applications are sandboxed and run across multiple servers. App Engine offers automatic scaling for web applications — as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.

Deploy using app engine

There are two ways you can deploy your NodeJS application:

  1. Using the Cloud Console
  2. Using local machine to deploy

First login using Google and open a Project Selector popup. Click new project and follow the prompts.

Using the Cloud Console

After creation, get into the Active Cloud Shell by clicking the icon provided in the image. The Active Cloud Shell provide a lot of utility from the get-go. For example it comes with node, git and gcloud pre-installed, so you don’t have to worry about installing anything.

Once you gained access into the terminal, pull down the repo that is meant to be deployed. Cd into your repo and create a new file called app.yaml using vim or the Text Editor. Inside of the file, there will be needed two scripts called runtime and env. Runtime is what type of runtime is used to run the server. In our case it would be nodejs. Env determines what kind of environment our app is running. In our case, we’ll use flex.

app.yamlruntime: nodejs
env: flex

Once all of that is done, then run gcloud app deploy app.yaml and the app is being deployed!

Using Local Machine

Using your local machine, doesn’t provide the benefit of having Cloud SDK installed. Cloud SDK lets you use gcloud commands that will be needed for deployment. Here are some in-depth, step-by-step docs: WindowsMacOS.

Once downloaded, use gcloud auth login. This command will redirect to login so the commands can refer to a specific account. Next step will be to gcloud init to connect to the project that was previously created. Then create an app.yaml using vim, touch or in the Text Editor which contains a runtime and env.

app.yamlruntime: nodejs
env: flex

The use gcloud app deploy and the app will be deployed!

--

--