Edit on GitHub
Report issue
Page history

Submitted by @{[ TutorialCtrl.tutorial.github_username ]} {[ TutorialCtrl.tutorial.date_published | date:'mediumDate' ]}

title: Deploying Apache Dropwizard applications on Google App Engine description: Learn how to deploy Apache Dropwizard applications on Google App Engine Flexible environment using a custom runtime. author: agentmilindu tags: App Engine, Apache, Dropwizard date_published: 2017-10-29

This tutorial shows how to deploy an Apache Dropwizard application on Google App Engine flexible environment.


Apache Dropwizard is a Java framework for developing RESTful web services which support for configuration management, application metrics, logging, operational tools, etc out of the box.

Deploying Dropwizard applications on Google App Engine Flexible Environment can be tricky because it requires you to pass arguments to the JAR, like java -jar app.jar server config.yaml in order to get the Dropwizard application running.

This tutorial shows how to make use of Google App Engine Flexible Environment's custom runtime to deploy an Apache Dropwizard application using Docker. This tutorial assumes that you are familiar with Apache Dropwizard and that you have installed Docker.

If you don't have a Dropwizard application already, you can check out getting started guide to create a sample Dropwizard application.


  1. Create a Dockerfile that bundles your JAR file and config.yml
  2. Run the Dropwizard app locally with Docker.
  3. Deploy the Dropwizard app to Google App Engine flexible environment.


This tutorial uses billable components of Google Cloud Platform, including:

  • Google App Engine flexible environment

Use the Pricing Calculator to generate a cost estimate based on your projected usage.

Before you begin

  1. Create a project in the Google Cloud Platform Console.
  2. Enable billing for your project.
  3. Install the Google Cloud SDK.

Preparing the app

  1. Build your application and generate your JAR artefacts.
  2. If you don't have a fat JAR (a JAR file with all the dependencies bundled together), generate one using a fat JAR plugin.

    1. You can use Apache Maven Shade Plugin.

      See example.pom.xml for example plugin configuration.

    2. Then you can build your app using:

      mvn package

      This will create a JAR file with all the dependencies of your application bundled together as one fat file.

      Note: Apache Shader renames your original package JAR sample-app-1.0-SNAPSHOT.jar into original-sample-app-1.0-SNAPSHOT.jar and creates the fat JAR with the name sample-app-1.0-SNAPSHOT.jar.

    3. (Optionally) you can rename the fat JAR using:

      See example.pom.xml for an example.

      The config in the example will create a fat JAR file named uber.jar instead of sample-app-1.0-SNAPSHOT.jar.

Create a Dockerfile

Create a file named Dockerfile in your project root and add the following:

 FROM gcr.io/google-appengine/openjdk:8

 COPY target/uber.jar uber.jar
 COPY config.yml config.yml
 CMD [ "java", "-jar","uber.jar", "server", "config.yml"]

Let's examine the lines in the Dockerfile:

The following defines what should be the base image for your Docker image:

FROM gcr.io/google-appengine/openjdk:8

The following copies your uber.jar into the Docker image:

COPY target/uber.jar uber.jar

The following copies your config.yml into the Docker image:

COPY config.yml config.yml

The following defines the command to be executed when running the Docker container, which runs your Dropwizard application on the Docker container:

CMD [ "java", "-jar","uber.jar", "server", "config.yml"]`:

Note: If you did not rename your fat JAR to uber.jar, replace uber.jar in the Dockerfile with your fat JAR name, which is like sample-app-1.0-SNAPSHOT.jar.

Run the app locally with Docker

  1. First, you should build your Docker image from the Dockerfile:

    docker build -t sample-app .


    docker build -t YOUR_DOCKERHUB_USERNAME/sample-app .

    -t options tell Docker what should be the tag for your Docker image. You can give a meaningful name to the tag.


    • You have to do this only once unless you update your Dockerfile, config.yml, or the fat JAR.
    • If you have a Docker Hub or any other Docker registry account or organization and you wish to push your Docker images there, you can prefix the username/organization name with the tag like -t YOUR_DOCKERHUB_USERNAME/YOUR_APP_NAME.
  2. Then, you can run the Docker image you just built:

    docker run -p 8080:8080 -t sample-app


    docker run -p 8080:8080 -t YOUR_DOCKERHUB_USERNAME/sample-app
  3. Visit http://localhost:8080 to see the running app.

  4. Press Ctrl+C to stop the app.

Deploying the app

  1. Create an app.yaml file with the following contents:

    runtime: custom
    env: flex
  2. Run the following command to deploy your app:

    gcloud app deploy
  3. Visit http://[YOUR_PROJECT_ID].appspot.com to see the deployed app.

    Replace [YOUR_PROJECT_ID] with your Google Cloud Platform project ID.


You might want to access Dropwizard's Admin context which usually runs on port 8081. However, since AppEngine does not allow port 8081, you can do a slight change in config and get both application and admin contexts to port 8080.

For that, you can add the following into your config.yml:

  type: simple
  applicationContextPath: /api
  adminContextPath: /admin
    type: http
    port: 8080

Now you can access the application API endpoint as http://[YOUR_PROJECT_ID].appspot.com/api and admin API endpoint as http://[YOUR_PROJECT_ID].appspot.com/admin.

See more by @{[ TutorialCtrl.tutorial.github_username ]} and more tagged {[ tag ]}{[ $last ? '' : ', ' ]}

Submit a Tutorial

Share step-by-step guides


Request a Tutorial

Ask for community help


GCP Tutorials

Tutorials published by GCP


Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.