Deploy Quarkus application to AWS Elastic Beanstalk

Elastic Beanstalk allows deploying and managing applications in the AWS Cloud without having to learn about the infrastructure that runs those applications.

With Elastic Beanstalk you can run a website, web application, or web API that serves HTTP requests but you can also run a worker applications for running long tasks. The Elastic Beanstalk supports several preconfigured platforms including Go, .NET or Java (Java 8 only) but also generic Docker platform.

You simply upload your application with AWS CLI, AWS EB CLI or with the Elastic Beanstack console, and Elastic Beanstalk automatically handles the rest.

In this blog post you will learn how to launch single container Docker environment with Quarkus based application on Elastic Beanstalk.

Note: This blog does not describe creating the application from scratch. Instead, it is basing on the Quarkus Pet Clinic REST API application that I created for Getting started with Quarkus blog post. The source code can be found on Github:

TL;DR: Create the package and upload to Elastic Beanstalk

Create new application in Elastic Beanstalk console

If you’re not already an AWS customer, you need to create an AWS account. Signing up enables you to access Elastic Beanstalk and other AWS services that you need.

Elastic Beanstalk will create the sample application for you with all required resources (including RDS).

The link to the application will be visible to you once the application is created.

Note: The above steps are based on the official documentation:

Preapare application package

  • Clone the repository
git clone
  • Navigate to the application directory and execute:
./mvnw clean package assembly:single -Dquarkus.package.uber-jar=true

The above command creates the package with the following contents:

$ unzip -l target/

Archive:  target/
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  03-15-2020 13:35   config/
     2059  03-15-2020 13:34   Dockerfile
      369  03-15-2020 13:34   config/
 38604205  03-15-2020 13:35   quarkus-petclinic-api-1.0.1-runner.jar
---------                     -------
 38606633                     4 files

Upload application to Elastic Beanstalk

  • Upload the package using Elastic Beanstalk console

That’s it. In the next paragraph you will learn how to prepare the package using Maven.

Step by step: Configure the application for Elastic Beanstalk

Runtime configuration

Let’s start with the application configuration specific for Elastic Beanstalk environment.

Quarkus offers a several options to override properties at runtime. I decided to utilize the approach with configuration file placed in config/ file. This file will be automatically read by Quarkus and all properties from this file take precendence over defaults.

Create src/main/resources/ file and set quarkus.http.port to 5000 as this is the default port for Elastic Beanstalk web application.

The next properties are related to the datasource configuration as the application will be connecting to the RDS (PostgreSQL). The RDS instance’s connection information are available to application running on Elastic Beanstalk through RDS_* environment properties which are available to running container. To use this set the following properties:


Read more on connecting your application to RDS:


Elastic Beanstalk uses Dockerfile to build and run the image. The file must be located in the root of the application’s directory. I used the original src/main/docker/Dockerfile.jvm and made following adjustments:

  • Copy config/ to the container
  • Expose port 5000 instead of 8080

The complete src/main/docker/Dockerfile.eb:


ARG JAVA_PACKAGE=java-11-openjdk-headless


# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install openssl curl ca-certificates ${JAVA_PACKAGE} \
    && microdnf update \
    && microdnf clean all \
    && mkdir /deployments \
    && chown 1001 /deployments \
    && chmod "g+rwX" /deployments \
    && chown 1001:root /deployments \
    && curl${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION} -o /deployments/ \
    && chown 1001 /deployments/ \
    && chmod 540 /deployments/ \
    && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/

ENV JAVA_OPTIONS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"

COPY *-runner.jar /deployments/app.jar
COPY config /deployments/config

USER 1001

ENTRYPOINT [ "/deployments/" ]

Create application package with Maven

Until now, the following two files were created:

  • src/main/resources/ with properties specific to Elastic Beanstalk environment
  • src/main/docker/Dockerfile.eb with container configuration for Elastic Beanstack environment.

To finish the configuration and configure package assembly, we will use Copy Rename Maven Plugin and Maven Assembly Plugin.

Prepare files for the assembly

Modify pom.xml and add the goal to copy and rename the files that will be stored in the final application package zip file:


The copy-file goal will run during package phase and will copy previously created files to target/eb with their names adjusted.

Configure assembly plugin

Maven Assembly Plugin will be used to create the application package. Add the below configuration to the pom.xml:


Now, create src/assembly/eb.xml descriptor that instructs the assembly plugin to create a zip containing Dockerfile, config/ and the Quarkus uber-jar. All three files will be located in the root of the archive:


This concludes the configuration. You can now create the package (assembly) by running:

With all the above changes, we can create the package:

./mvnw clean package assembly:single -Dquarkus.package.uber-jar=true

Test the package locally

To test the package locally run:

unzip target/ -d target/eb-dist && cd target/eb-dist
docker build -t quarkus/petclinic-api-jvm-eb .

Before running the container, start the database:

docker run -it --name petclinic-db -p 5432:5432 -e POSTGRES_DB=petclinic -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -d postgres:11.6-alpine

Run the application passing RDS environment variables and link to the database container:

docker run -i --rm -p 8080:5000 --link petclinic-db -e RDS_HOSTNAME=petclinic-db -e RDS_PORT=5432 -e RDS_DB_NAME=petclinic -e RDS_USERNAME=petclinic -e RDS_PASSWORD=petclinic quarkus/petclinic-api-jvm-eb

Open http://localhost:8080 in your browser and you should see the home page.

Source code

The source code for this article can be found on Github:


See also

Popular posts from this blog

Parameterized tests in JavaScript with Jest