How to Launch With Spring Boot 2 and Java 9 On Google App Engine Flex Environment

spring-boot-google-app-engineStruggling to get your Java 9 app launched on Google App Engine? It’s probably because all of the docs say only up to Java 8 is supported. It may not be publicized, but there does exist a docker image for openjdk9 on Google App Engine. Here’s how you can use it.

First of all, I’m about to make a lot of assumptions about how much you’ve worked with Google App Engine, which means I’m going to stick to the parts that are specific to adding Java 9 support. To that end, the first thing you’ll need to do is create a src/main/appengine/app.yaml with the following:

app.yaml

runtime: custom  # we will be using a custom docker image
env: flex        # we will be using the flex environment

At this point we’ve basically told App Engine that we want to provide our own docker image and that we want to use App Engine’s flexible environment.

Next, we need to provide our src/main/docker/Dockerfile:

Dockerfile

FROM us.gcr.io/google-appengine/openjdk:9
COPY our-spring-boot2-app.jar $APP_DESTINATION

What we’ve done here is reference a “super secret” openjdk 9 tag in Google’s docker registry as our base image. Then, we simply copy our artifact into place, resolved automatically by $APP_DESTINATION. Note that the artifact name, in this case our-spring-boot2-app.jar, must match the final build name of your artifact.

That’s it! Your Spring Boot 2 App with Java 9 will now launch just fine on Google App Engine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s