Deploying a Vaadin Application to Google Cloud

This tutorial shows you how to deploy a Vaadin application to Google Cloud App Engine. Google Cloud has free-trial and free-tier offerings that you can read more about on Google Cloud website.

Note
Google Cloud account required
To complete this tutorial, you need to sign up for a Google Cloud account at https://cloud.google.com/. Your Google Cloud account should also have the billing enabled.

Step 1: Install and Setup Google Cloud SDK

To begin, download and install the Google Cloud SDK.

Once installed, run the following command from a terminal window to add the App Engine support for Java to the SDK.

gcloud components install app-engine-java

Step 2: Download a Starter App

Download a minimal Vaadin project and unpack the downloaded zip into a folder on your computer.

Step 3: Initialize a Google Cloud Project

Open the project directory from a terminal window, and enter the following command to initialize a Google Cloud Project:

gcloud init

If this is your first time running Google SDK, you will be asked to authenticate your account. When prompted to login, enter 'Y' and allow the SKD to control your account in the opened browser window.

Once authenticated, you will prompted to select a configuration. Enter '1' to select the default configuration as in the following snippet:

Settings from your current configuration [default] are:
accessibility:
  screen_reader: 'False'
core:
  account: john.doe@gmail.com
  disable_usage_reporting: 'True'

Pick configuration to use:
 [1] Re-initialize this configuration [default] with new settings
 [2] Create a new configuration
Please enter your numeric choice:  1

Step 4: Create an App Engine Instance

From a terminal window at the project’s root directory, create a Google App Engine instance using the following command:

gcloud app create

You will then be asked to select a region. Feel free to choose a region that is the most proximate to your users.

Step 5: Create a Production Build

Open the project directory from a terminal window, and enter the following command to generate a JAR file of your application:

mvn package -Pproduction

Step 6: Deploy the Application

From a terminal window at the project root directory, enter the following command to deploy the application to Google Cloud:

gcloud app deploy target/myapp-1.0-SNAPSHOT.jar

When the deployment completes, the application URL will be displayed in the logs.

Note
Ensure Google Cloud billing is enabled
If the deployment fails with an error similar to ERROR: (gcloud.app.deploy) Error Response: [7] Access Not Configured., then ensure that your Google Cloud account has billing enabled. Once enabled try the deployment again.