Architektur

Spring-Boot and Oracle Application Container Cloud

Oracle ACC and Spring-Boot
Carsten Wiesbaum
Carsten Wiesbaum

Microservices as an architectural style as well as scalable and manageable cloud infrastructure are the foundation for modern and flexible business applications. Therefore, Oracle invested heavily in maturing its Cloud portfolio and providing services to support development and operations of such applications. One Oracle cloud service aimed at these kind of applications is “Oracle Application Container Cloud Service” (ACC). It provides a simple Docker based environment in which your Microservices can be deployed. In order to reduce the operations overhead, developers only have to provide their applications (NodeJS, Java SE or PHP) in a certain format and Oracle’s cloud infrastructure takes over.

Within this blog article required design considerations for developing and running a Spring-Boot application on Oracle’s ACC Service are described.

ACC Design Considerations and Spring-Boot

Oracle prescribes three basic design considerations when planning to run applications within Oracle ACC Service. First of all, ACC is dynamically creating Docker containers. As result hostname and port can only be determined during runtime. Therefore, applications deployed within ACC containers must be able to listen on specific ports. Secondly, in order to use the dynamically created container port and hostname an application has to be configurable during runtime. The ACC infrastructure provides its hostname and port within two environment variables, HOSTNAME and PORT. An application running in ACC must be able to access these variables and use them for application configuration. Finally, an application should include all of its dependencies.

When looking at these design principles Spring-Boot is a perfect choice in order to develop a Microservice and run it on Oracle ACC. Although Spring-Boot applications follow the principle convention over configuration and need just a minimum of configuration to run, they are indeed highly configurable at runtime. In order to run in ACC only two properties need to be configured within a Spring-Boot application:

Furthermore, Spring-Boot applications can be packages as single executable JAR file containing all dependencies. Therefore, it should be possible to run Spring-Boot Microservices on Oracle ACC. But which steps are required in order to get it up into the cloud and running?

Preparing the Spring-Boot Application

In order to prepare a Spring-Boot application to run on Oracle ACC, application metadata and a deployment ready archive have to be prepared. When using Oracle ACC the application’s metadata is described within a manifest.json file. Within this file information such as runtime versions, launch commands, startup time and shutdown time thresholds are defined. For a full definition see Oracle’s documentation (links below). For this example the manifest.json file looks as follows:

As one can see the application shall run on Java SE Version 8. In order to provide the application with the container’s hostname and port, both values are passed to the application within our launch command (–server.port & –server.address). In addition, an optional file named deployment.json can be provided. Within this file one can specify how many instances of the service are started, how much memory is allocated and if any bindings to other services exist.

After defining required metadata files they have to be packaged with the application to a deployment ready archive. The archive can either be in ZIP or TAR-GZ format. In order to create a TAR-GZ archive the following command can be used:

Now application preparation is finished and it can be deployed to Oracle ACC.

Deploying the Application to Application Container Cloud

Now that the application is prepared, it is ready to be deployed into Oracle ACC. Within this blog post we will focus on using ACC Service Console. An alternative is to use the RESTful API provided by Oracle.  First of all, one has to login to the Oracle Cloud account. From CLOUD My Services Dashboard navigate to Oracle ACC Service Console and click on the „Create Application” button.

Create Oracle Application Container Cloud Application

Create Oracle Application Container Cloud Application

On the next screen the “Create Application” dialogue is displayed. Besides providing the prepared deployment ready archive and some application metadata nothing is required. When all required metadata is provided, click on “Create”.

Oracle ACC Create Application

Oracle ACC Create Application

Now the application dashboard is displayed and Oracle ACC starts to initialize a Docker container and run the application. After the application is started, it can be accessed using the URL provided within the application’s dashboard.

Oracle ACC Application Provisioning

Oracle ACC Application Provisioning

Summary

Within this blog we described on how Spring-Boot applications have to be prepared in order to be deployed to Oracle’s Applicaion Container Service. In general, Spring-Boot is a perfect fit in order to run Java SE applications within this cloud infrastructure. Only a few design principles have to be taken into account and some metadata has to be added. Afterwards an application can be deployed. Still there are some open questions which might be of interest in order to run enterprise ready applications on Oracle ACC:

  • How can multiple Microservices be combined to a single application?
  • How can Microservices running on ACC be monitored?
  • How can applications be deployed to Oracle ACC using common build tools?

Those questions will be addressed in future blog posts.

Links

Oracle ACC Design Considerations – http://docs.oracle.com/en/cloud/paas/app-container-cloud/dvcjv/design-considerations.html

Spring-Boot Externalized Configuration – https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

Spring-Boot Common Properties – https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html