Search code examples
javagoogle-app-enginedeploymentarchive

Deploying an App Engine application using an archive file [jar/war]


Even though we have access to the google documentation about this topic here, I’ve thought hard to follow all the instructions once we need to have Eclipse installed. To make matters worse, I haven’t found anything on the internet that could help me to deploy an .war file using an App Engine of Google Cloud Computing (GCP).

Context

In my specific case, I coded an application using Bazel + Guice (bazel-guice-app) and I didn’t find any easy tutorial explaining how to deploy it without installing anything (of course, we need to install GCP SDK).

Goal

Deploy an application in App Engine using .war/.jar files.


Solution

  • As well as did Google tutorial, to deploy a pre-existing WAR or runnable JAR file we need to start setting up an app.yaml file with flexible environment, java runtime and with our jar/war file:

    runtime: java
    env: flex
    handlers:
      - url: /.*
      script: <file_name>.war
    

    N.B.: it assumes your app.yaml file is located in the same folder of your jar/war file.

    Once we have our .yaml file we can deploy our application running the following gcloud command (you must have GCP SDK installed or use GCP cloud shell):

    gcloud app deploy app.yaml
    

    Simple as you can see, we just need to wait for the deploy process to finish.