{{announcement.body}}
{{announcement.title}}

Deploy Quarkus Faster in the Cloud With Platform.sh Part 3: PostgreSQL With Panache

DZone 's Guide to

Deploy Quarkus Faster in the Cloud With Platform.sh Part 3: PostgreSQL With Panache

How to deploy a Panache/PostgreSQL Quarkus application in the cloud with Platform.sh

· Java Zone ·
Free Resource

Quarkus is, in its own words, a Cloud Native, (Linux) Container First framework for writing Java applications. It has become popular because of the amazingly fast boot time and incredibly low RSS memory. In this series of articles about Quarkus, we'll teach how to deploy Quarkus with Panache.

Hibernate ORM is the de facto JPA implementation and offers you the full breadth of an Object Relational Mapper. It makes complex mappings possible, but it does not make simple and common mappings trivial. Hibernate ORM with Panache focuses on making your entities trivial and fun to write in Quarkus.

The first step is to create the application itself, and Quarkus has proper documentation. You have either a Maven Archetype or the start code link where you can define the dependencies that you need to write your application.

In the maven project, we either add manually or from the start site the Hibernate Panache ORM,  JDBC driver, and the data source dependency.

XML


We need to configure the application to run locally to test it.

Properties files


If you want to run a PostgreSQL locally, a good option might be a Docker, that you can run with the command below:

Shell


The infrastructure code is ready; the next step is to create the application itself. In this sample, we'll create a small rest-application to store cars where we have a plate, make, and model. Therefore, we'll create a Car entity.

Java


The last step is to create a resource where the client can do request and then the CRUD. As we can see, with Panache, we can reduce a lot of complexity of the code.

Java


The application is ready to go, you can run the test the application. The next step is to move to the cloud with Platform.sh.

To move your application to the cloud, briefly, you need three files:

YAML


Platform.sh allows you to completely define and configure the topology and services you want to use on your project.

YAML


One or more application containers (.platform.app.yaml). You control your application and the way it will be built and deployed on Platform.sh via a single configuration file. This application will grand permission to access PostgreSQL.

YAML


The application is now ready, so it’s time to move it to the cloud with Platform.sh using the following steps:

  • Create a new free trial account.
  • Sign up with a new user and password, or login using a current GitHub, Bitbucket, or Google account. If you use a third-party login, you’ll be able to set a password for your Platform.sh account later.
  • Select the region of the world where your site should live.
  • Select the blank template.

You have the option to either integrate to GitHub, GitLab, or Platform.sh will provide to you. Finally, push to the remote repository.

Done! We have a simple and nice Quarkus application ready to go to the cloud.

Topics:
cloud ,java ,paas ,platform.sh ,postgres ,quarkus ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}