Testing and Deploying your Application

Learn how to run your application locally, deploy it, and test on App Engine.

Running locally

To test your application's functionality before deploying, run your application in your local environment with the development tools that you usually use.

For example, npm start.

Deploying your application

Deploy your application to App Engine using the gcloud app deploy command.

During deployment, the Container Builder service builds a container image of your application to run in the App Engine standard environment. Learn more in Managing build images.

To programmatically deploy your apps, use the Admin API.

Before you begin

Before you can deploy your application:

Deploying a service

You deploy your application to App Engine by deploying versions of your application's services and each of their configuration files.

To deploy a version of your application's service, run the following command from the directory where the app.yaml file of your service is located:

gcloud app deploy

Specifying no files with the command deploys only the app.yaml file in your current directory. By default, the deploy command generates a unique ID for the version that you deploy, deploys the version to the GCP project you configured the gcloud tool to use, and routes all traffic to the new version.

You can change the default behavior of the command by targeting specific files or including additional parameters:

  • To deploy the other configuration files of your service, you must target and deploy each file separately. For example:

    gcloud app deploy cron.yaml
    gcloud app deploy dispatch.yaml
    gcloud app deploy index.yaml
    
  • To specify a custom version ID, use the --version flag.

  • To prevent traffic from being automatically routed to the new version, use the --no-promote flag.

  • To deploy to a specific GCP project, use the --project flag.

For example, to deploy the service defined by app.yaml to a specific GCP project, assign it a custom version ID, and prevent traffic from being routed to the new version:

gcloud app deploy --project PROJECT_ID --version VERSION_ID --no-promote

For more information about this command, see the gcloud app deploy reference.

Deploying multiple services

You use the same deployment command for deploying or updating the multiple services that make up your application.

To deploy multiple services, you must separately deploy each service's app.yaml file. For example:

gcloud app deploy service1/app.yaml
gcloud app deploy service2/app.yaml

You can specify multiple files with a single deploy command:

gcloud app deploy service1/app.yaml service2/app.yaml

Requirements for deploying multiple services

  • You must initially deploy a version of your application to the default service before you can create and deploy subsequent services.

  • The ID of each of your services must be specified in their corresponding app.yaml configuration files. To specify the service ID, include the service element definition in each configuration file. By default, excluding this element definition from your configuration file deploys the version to the default service.

Ignoring files

You can use a .gcloudignore file to specify files and directories not to upload to GCP when you deploy your services. This is useful for ignoring build artifacts and other files that do not need to be uploaded with your deployment.

If you do not have a .gcloudignore file in your service's directory, the gcloud tool automatically creates a default .gcloudignore file when you deploy. The default file contains the following:

.gcloudignore
.git
.gitignore
node_modules/

The listed files and directories will not be uploaded to GCP.

Learn more about the syntax of the .gcloudignore file in the gcloud reference.

Managing build images

Each time you deploy a new version, a container image is created using the Container Builder service. That container image then runs in the App Engine standard environment.

Built container images are stored in the app-engine folder in Container Registry. You can download these images to keep or run elsewhere. Once deployment is complete, App Engine no longer needs the container images. Note that they are not automatically deleted, so to avoid reaching your storage quota, you can safely delete any images you don't need. For more information about managing images in Container Registry, see the Container Registry documentation.

Viewing your application

After you deploy your application to App Engine, you can run the following command to launch your browser and view it at http://YOUR_PROJECT_ID.appspot.com:

gcloud app browse

Testing on App Engine

Before configuring a new version to receive traffic, you can test it on App Engine. For example, to test a new version of your default service:

  1. Deploy your new version and include the --no-promote flag:

    gcloud app deploy --no-promote
  2. Access your new version by navigating to the following URL:

    http://VERSION_ID.default.YOUR_PROJECT_ID.appspot.com
    

    Now you can test your new version in the App Engine runtime environment. You can debug your application by viewing its logs. For more information, see Writing Application Logs.

    Requests sent to http://YOUR_PROJECT_ID.appspot.com will still be routed to the version previously configured to receive traffic.

  3. When you want to send traffic to the new version, use the GCP Console to migrate traffic:

    Manage versions

    Select the version you just deployed and click Migrate traffic.

You can use the same process to test new versions of other services by replacing default in the URL with your service's name:

http://VERSION_ID.SERVICE_ID.YOUR_PROJECT_ID.appspot.com

For more information about targeting specific services and versions, see How Requests are Routed.

Was this page helpful? Let us know how we did:

Send feedback about...

App Engine standard environment for Node.js docs