Erik V.
Erik V.

Reputation: 41

How to deploy Play! framework app to Openshift v3

Perhaps I pop this question to early as Openshift v3 is still in preview, nevertheless there might be a solution to my problem that I don't see :).

I'm taking my first steps in building a java Play framework app and chose Openshift as my hosting platform. I just was able to get my app + mysql db working on Openshift v2 as they released v3 preview and got notice v2 will eventually disappear. In the new images/templates there is still no Java Play version showing and no 'do it yourself cartridge' way.

Any hints or 'tutorial' links are much appreciated :).

Thanks and kind regards! Erik

Upvotes: 3

Views: 796

Answers (2)

Erik V.
Erik V.

Reputation: 41

For everyone looking for an answer to my own question, here is how I got a Play app running on Openshift (own installation). First of all, a big thank you @PatrickTescher. His answer pointed me in the right direction.

I did not yet succeed in getting a docker build by activator to work in Openshift (guessing it has to do with running under root), but I have gotten to the point where I have a Source to Image build running on my own Openshift Cluster. This approach is not yet possible with the online developer preview of Openshift. By all the reading I have done so far, I agree with Patrick to say this is the best approach.

By diving into the following links, you should get up and running:

In the last link you can change registry.access.redhat.com/rhel7.2 by registry.centos.org/centos/centos:latest (rhel needs certification, centos is the free community equivalent)

Upvotes: 1

Patrick Tescher
Patrick Tescher

Reputation: 3447

You have two options here.

SBT Native Packager

First option would be using the SBT Native Packager SBT builder to create your Docker images (either manually or using something like Jenkins). Out of the box you should be able to run sbt docker:publishLocal and get a local docker image which you can then push to a Docker repo. You can then launch it in openshift with oc new-app <docker repo>/<docker image>:<image version>.

Down side to this is that you aren't really taking advantage of OpenShift fully since your images are being built elsewhere. But it might fit well with your current development flow.

Upside is that your docker images will be quite small. SBT does a good job of packaging up all the dependencies.

Source to Image

Second option would be to create your own source to image builder that knows how to build sbt/play projects. This is the path my team has taken. You can take a look at our sbt builder for reference but its still beta quality at best.

Downside to this process is that all your source is included in the image so its a big larger. Also no one supports this builder so if you have bugs you are on your own.

Upside is that OpenShift will build your images and you will see your build status inside the OpenShift web console.

Notes

With OpenShift Origin 1.3.0 you will also get access to the Jenkins pipeline. This can make either of the two above scenarios easier. You end up with a cool web interface that looks like this:

OpenShift Build Pipeline Screenshot

Hopefully RedHat will support sbt natively at some point but for now one of these two flows should work for you.

Upvotes: 2

Related Questions