App Engine
Deploy a JAR to a fully managed PaaS with just one command.
App Engine is a fully managed Platform-as-a-Service that can run your application, provision a HTTPS load balancer, and scale out your workload as needed. When no one is using your application, it can scale down to zero.

Getting Started

Clone

1
cd $HOME
2
git clone https://github.com/saturnism/jvm-helloworld-by-example
3
cd jvm-helloworld-by-example/helloworld-springboot-tomcat
Copied!

Build

1
./mvnw package
Copied!

Deploy

1
gcloud app deploy target/helloworld.jar
Copied!
If this is your first time using App Engine on the project, you'll be prompted to choose a region. Pick the region that's most suitable for your application. This site mostly uses us-central as an example.
Once you select the region, you cannot change it for an App Engine application.

Connect

Once deployed, the command will output the HTTPs URL. To open the URL in your browser:
1
gcloud app browse
Copied!
To find the URL without opening the browser:
1
gcloud app browse --no-launch-browser
Copied!
You can curl the URL:
1
URL=$(gcloud app browse --no-launch-browser)
2
curl ${URL}
Copied!
You can run any Java service in App Engine as long as it's packaged as a JAR file, and can be executed with java -jar app.jar.

Additional Configuration

By default, App Engine will deploy with the smallest F1instance class. You can specify a larger instance, configure environment variables, and more tuning parameters using an app.yaml:
app.yaml
1
runtime: java11
2
instance_class: F4
3
env_variables:
4
SPRING_PROFILES_ACTIVE: "prod"
Copied!
See App Engine Standard Instance Classes documentation for a list of Instance Classes and associated CPU/Memory resources.
Deploy the JAR file with the configuration:
1
gcloud app deploy target/helloworld.jar \
2
--appyaml app.yaml
Copied!
Learn more about the configurations in app.yaml reference documentation.

Learn More

Last modified 1yr ago