Deploying a Go App

Deploy your app to upload and run them on App Engine. When you deploy your apps, you create versions of those apps and their corresponding services in App Engine. You can deploy entire apps, including all the source code and configuration files, or you can deploy and update individual versions or configuration files.

Before you begin

You must download and install the App Engine Go SDK , which includes the goapp and appcfg tools:

Download the SDK

Using a proxy

If you are running the deployment command from a system which uses an HTTP or HTTPS proxy, you must configure the tool so that it can communicate via the proxy.

Set the environment variable that corresponds to your proxy:

Windows

set HTTP_PROXY=http://cache.example.com:3128
set HTTPS_PROXY=http://cache.example.com:3128

Mac / Linux

export HTTP_PROXY="http://cache.example.com:3128"
export HTTPS_PROXY="http://cache.example.com:3128"

Deploying an app

To deploy your app to App Engine, you run the goapp deploy command from within the root directory of your application where your configuration files are located, for example app.yaml.

goapp deploy

Alternatively, you can provide the location of your application's root directory as an additional argument. For information about using the tool, run the goapp help deploy command.

The tool automatically uses the application ID from your app.yaml file. However, many of our sample applications omit application: from the app.yaml file, as well as version:. Therefore, you must ensure that a Cloud Platform Console project ID is specified for the application ID along with the version ID of your choice, for example:

goapp deploy -application [YOUR_PROJECT_ID] -version [YOUR_VERSION_ID] [YOUR_APP_DIR]

By default, the initial version that you deploy to a service is automatically configured to receive 100% of traffic. However, all subsequent versions that you deploy to the same service must be manually configured, otherwise they receive no traffic.

Deploying multiple service applications

When your application is factored into multiple services, you can deploy and update individually targeted services or all the services simultaneously. Deploying updates to services can include updating individual configuration files or updating the source code in the corresponding versions.

For example, you can deploy and create two versions in App Engine, where each version runs in their own service. The first version serves as the frontend service and the other as the backend of your app. You can then deploy individual configuration files to update only the settings of a service. You can also choose to deploy a new version to a service in order to update the source code of the frontend, backend, or both simultaneously.

Requirements for multiple services

You use the same deployment commands for deploying and updating the multiple services of your application with the following requirements:

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

  • You must specify the ID of your service in the app.yaml configuration file of the corresponding version. To specify the service ID, you include the module: [YOUR_SERVICE_ID] element definition in each configuration file. By default, excluding this element definition from your configuration file deploys the version to the default service.

  • You must specify all the corresponding app.yaml configuration files in your deployment command to simultaneously deploy multiple services. The `default` service must be listed first.

To deploy multiple services

From the root directory of the application where the configuration files are located, you run the deployment command and specify the relative paths and file names for each service's app.yaml file:

goapp deploy [DEPLOYMENTS]

Where [DEPLOYMENTS] is one or more configuration file's path and name. You separate each configuration file that you specify with a single white space.

Example

goapp deploy main/app.yaml service1/app.yaml service2/app.yaml

You will receive verification via the command line as each service is successfully deployed.

Updating indexes

If your app's index.yaml file defines an index that doesn't yet exist, App Engine will create it after you upload your app.

It can take a while for App Engine to create all the indexes. If your app is already configured to receive traffic, any query that requires one of the missing indexes will raise an exception until that index is built.

To avoid exceptions you must allow time for the indexes to build, for example:

Troubleshooting

The following are common error messages that you might encounter:

Command not found

If you did not create symlinks for the appcfg.py or dev_appserver.py tools when you installed the App Engine SDK, you might need to specify the full directory path to run the tool, for example: [PATH_TO_APP_ENGINE_SDK]/appcfg.py or [PATH_TO_APP_ENGINE_SDK]/dev_appserver.py .

[400] The first service (module) you upload to a new application must be the 'default' service (module)

Before you can deploy and create the multiple services of your application, you must first deploy and create the default service. For details about how to deploy a version to the default service, see Deploying multiple service applications.

Too Many Versions (403)

App Engine has a limit on the number of deployed versions of your application. These differ for free applications and deployed applications. You can use the Cloud Platform Console to delete an older version and then upload your latest code.

You do not have permission to modify this app (403)

This can occur when the account that you are authenticated as does not have permission to deploy to the application ID that is specified in your command or in your app.yaml. Check your application ID is accurate and matches the value of your Cloud Platform Console project ID. Next, check the project permissions in the console and verify that your account is listed with a sufficient permission level to allow for deploying apps. If the account permission and project ID appear correct, you can try to force a reauthentication of your SDK by removing the .appcfg_oauth2_tokens file from your home directory and retry the deployment commands.

What's next

Send feedback about...

App Engine standard environment for Go