Deploying a Hilla Application to Google Cloud
- Step 1: Install and Set Up the Google Cloud SDK
- Step 2: Download a Starter App
- Step 3: Initialize a Google Cloud Project
- Step 4: Create an App Engine Instance
- Step 5: Create a Production Build
- Step 6: Deploy the Application
This tutorial shows you how to deploy a Hilla application to Google Cloud App Engine. Google Cloud has free-trial and free-tier offerings that you can read more about on the 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 billing enabled.
|
Step 1: Install and Set Up the Google Cloud SDK
To begin, download and install the Google Cloud SDK.
After it’s installed, run the following command from a terminal window to add App Engine support for Java to the SDK.
gcloud components install app-engine-java
Step 2: Download a Starter App
Download a minimal Hilla project and unpack the downloaded zip into a folder on your computer.
npx @hilla/cli init my-app
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 log in, enter Y and allow the SDK to control your account in the opened browser window.
After authentication, 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, in the project root directory, create a Google App Engine instance using the following command:
gcloud app create
You will then be asked to select a region. You may want to choose the region that’s geographically closest 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, in 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 has finished, the application URL will be displayed in the logs.
Note
|
Ensure that Google Cloud billing is enabled
If the deployment fails with an error similar to ERROR: (gcloud.app.deploy) Error Response: [7] Access Not Configured. , ensure that your Google Cloud account has billing enabled.
When it’s enabled, try the deployment again.
|