> For the complete documentation index, see [llms.txt](https://spring-gcp.saturnism.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spring-gcp.saturnism.me/getting-started/helloworld/app-engine.md).

# App Engine

[App Engine](https://cloud.google.com/appengine/docs/standard/java11) 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.

{% embed url="<https://www.youtube.com/watch?v=qx_T6-EKkBE>" %}

## Getting Started

### Clone

```bash
cd $HOME
git clone https://github.com/saturnism/jvm-helloworld-by-example
cd jvm-helloworld-by-example/helloworld-springboot-tomcat
```

### Build

```bash
./mvnw package
```

### Deploy

```bash
gcloud app deploy target/helloworld.jar
```

{% hint style="info" %}
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.
{% endhint %}

{% hint style="warning" %}
Once you select the region, you cannot change it for an App Engine application.
{% endhint %}

### Connect

Once deployed, the command will output the HTTPs URL. To open the URL in your browser:

```bash
gcloud app browse
```

To find the URL without opening the browser:

```bash
gcloud app browse --no-launch-browser
```

You can `curl` the URL:

```bash
URL=$(gcloud app browse --no-launch-browser)
curl ${URL}
```

{% hint style="info" %}
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`.
{% endhint %}

## Additional Configuration

By default, App Engine will deploy with the smallest `F1`instance class. You can specify a larger instance, configure environment variables, and more tuning parameters using an `app.yaml`:

{% code title="app.yaml" %}

```
runtime: java11
instance_class: F4
env_variables:
  SPRING_PROFILES_ACTIVE: "prod"
```

{% endcode %}

{% hint style="info" %}
See [App Engine Standard Instance Classes documentation](https://cloud.google.com/appengine/docs/standard#instance_classes) for a list of Instance Classes and associated CPU/Memory resources.
{% endhint %}

Deploy the JAR file with the configuration:

```bash
gcloud app deploy target/helloworld.jar \
  --appyaml app.yaml
```

{% hint style="info" %}
Learn more about the configurations in [app.yaml reference documentation](https://cloud.google.com/appengine/docs/standard/java11/config/appref).
{% endhint %}

## Learn More

* [App Engine Java 11 documentation](https://cloud.google.com/appengine/docs/standard/java11)
* [Deploy with App Engine Maven plugin](https://cloud.google.com/appengine/docs/standard/java11/using-maven#setting_up_maven)
* [Deploy with App Engine Gradle plugin](https://cloud.google.com/appengine/docs/standard/java11/using-gradle)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://spring-gcp.saturnism.me/getting-started/helloworld/app-engine.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
