The Personal Blog of Todd Sharp

Intro To Oracle Application Container Cloud Services

Posted By: Todd Sharp on 5/2/2018 4:35 GMT
Tagged: Spark Java

I've long been an AWS user, but recently one of my projects at work has expressed some interest in getting our platform running on multiple cloud service providers so based on the recommendations of a few friends I decided to give Oracle's cloud offering a look.  I'd heard a bit about their cloud offerings, but I honestly had no idea just how many services they offered.  I mean, seriously - everything from application/container hosting to messaging queues, security, AI, Machine Learning - you name it and they seem to offer a product or service to support it.  I guess it really shouldn't surprise me though - cloud services are undeniably the future of our industry.

To get started I thought I'd just throw together a basic "hello world" application.  First things first, I signed up for a free trial.  They give you $300 credit for 30 days so it's easy to take a look at their offerings without a financial commitment (and I've yet to be called and bugged by a salesperson into signing up for a contract, so that's good!).  I do feel like a free tier would make Oracle's offerings much more attractive - especially to developers looking to host a simple blog or smaller project or just to tinker with their services for a longer period of time.  To be fair, the AWS free tier is pretty limited and is still time bound (most free tiers expire after 12 months). I don't even use the free tier for my blog, but it is a nice option to use at least as a "playground" for their services that gives you plenty of time to fully evaluate them.

The nice thing about Oracle's Application Container Cloud Service (which, from here on out I'll be abbreviating ACCS for the sake of brevity!) is that it supports pretty much any kind of application. You might think that Oracle would be strictly focused on Java applications, but that's not the case. Of course, support for Java (SE and EE - or I guess Jakarta EE as it's now known) is there, but so is support for Node.JS, PHP, Ruby, Python, Go and .NET. The other nice thing is that ACCS is Docker based - but you'd never know it because all you have to do is deploy your application archive (a JAR in my case) and it handles the container creation, configuration and deployment. Which is really nice, but sometimes you want more granular control over the container creation and configuration - and in those cases Oracle has a solution, but it's not ACCS. Sometimes you just need a microservice deployed and don't need to fuss over the details - and that's where ACCS shines in my opinion. Finally, Oracle gives you multiple deployment options: a web based interface, full REST API (which could be useful CI/CD pipeline integration) and a full featured CLI. For this demo we'll take a look at the web based interface, but I may take a deeper dive into the CLI in the near future since it offers the ability to do things like deploy directly from a source control (GitHub) repo.

I figured my Spark Java "Skeleton" app would be the perfect place to start so I cloned it and made some slight modifications in order to make it work with ACCS.  The first thing I needed to do was make sure that I created a "fat" JAR (that is, a JAR file with all the dependencies bundled within it - ready to be executed).  To do so, I made a few modifications to my build.gradle.  The first step was to add a jar task:

I also added a few additions to make sure my config files ended up in the JAR file:

Finally, I added a packageOracle task to zip up the resulting JAR file along side a manifest.json file per the ACCS documentation (we'll look at my manifest.json next):

The manifest.json file is a JSON file that provides some necessary information used in the creation of the Docker container and in launching the application.  Mine is shown below, but yours might look different depending on the choices you've made when creating your application (language choice, for one, would result in a different 'command' value):

The only other modification to my Spark Java app that was necessary was to grab the port assigned by ACCS and pass it to Spark Java. ACCS sets the port (and the hostname) into your environment properties, so here's how I modified my application to account for that:

Once I made those modifications and ran my packageOracle task I was ready to deploy my application to ACCS.  To create the application, I logged in to the ACCS console and selected 'Create Application' from the dashboard.

In the 'Create Application' dialog, you have to choose your application platform.  Since I'm deploying a JAR file, I chose 'Java SE'.

In the next dialog, I named my application, chose the ZIP file (that contains my manifest.json and my fat JAR), select how many instances, how much memory and which region I'd like the application deployed to.

After clicking 'Create' I get a confirmation that the creation request was accepted.  

Clicking into the application for more details presents you with the following view.  

Once the application is created and deployed (a few minutes) I was able to click on the URL at the top of the page to view my running application.

As I stated earlier, ACCS gives you the ability to deploy via the CLI directly from GitHub, however there are a few limitations at this time (Java SE, Maven based builds only).  Probably the most commonly used option would be to deploy via the REST API, since any CI/CD pipeline absolutely needs the ability to remotely publish an application.  See the docs for more info.

If you'd like to see the full application source you can find it on GitHub.

Image by TheDigitalArtist from Pixabay

Related Posts

Creating A Slack Clone With Twilio, Angular 5 And Electron

Creating A Slack Clone With Twilio, Angular 5 And Electron

I've heard plenty about Twilio over the past few years and had always wanted to learn more about their APIs.  They have a ton of different products...

Spark Java "Flash" Scope

Spark Java "Flash" Scope

One of the handiest features of Grails is the "flash" scope.  The flash scope is "A temporary storage map that stores objects within the session for...

Realtime GPIO On Raspberry Pi With Spark Java And WebSockets

Realtime GPIO On Raspberry Pi With Spark Java And WebSockets

One of the cooler things about the Spark Java framework is built in websocket support thanks to the embedded Jetty server.  I've long been fascinated...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!