Deploying stubby4j / Core java app in cloud foundry

286 Views Asked by At

I may sound idiotic and I guess I am asking an incorrect design question but just wanted to know your view point.

I want to start jetty container from one of my CloudFoundry app, Is it possible to do so , I guess the answer is no as it will be case of container inside other container, Please help.

Whats the real question:

I am trying to stub some of the other rest api that i will call from one of my cloud foundry app and for that I am using Stubby4J which is a good REST mockign system that starts jetty container. Jetty its not starting from inside my cloud foundry app as it requires a port etc.

I guess I need to change my approach and run my stubby4j application as a separate application ( as a core java app in cloud foundry ) that can be invoked from any cloudfoundry app

Please suggest.

2

There are 2 best solutions below

0
On

I am not sure if this is still relevant to the OP, but it is possible to deploy stubby4j in a Docker container. See the https://stubby4j.com/#running-in-docker and check official stubby4j Docker images hosted on https://hub.docker.com/r/azagniotov/stubby4j

0
On

Not idiotic at all, this is a valid question.

I want to start jetty container from one of my CloudFoundry app, Is it possible to do so ,

Yes, it is possible. There are a few options.

1.) The easiest option would be to embed Jetty into your application and deploy it as an executable JAR file. The Java build pack on CF will take executable JAR files and simply run it (i.e. java -jar ).

2.) You can fork the Java build pack and add support for Jetty. In this way, you could deploy a WAR file and have the build pack stage it onto a Jetty server.

3.) You could use a non-default build pack. I see there's a Jetty BP available here.

4.) You could fork and customize the Java Build Pack or even just create your own build pack. This would ultimately give you the most control over how your application is deployed on CF.

Jetty its not starting from inside my cloud foundry app as it requires a port etc.

When running Jetty embedded (or really anything embedded), this is a legit concern. With a WAR file, the Java BP will make sure that the application is deployed and listening on the correct port. If you embed a server, you need to make sure it's configured to listen on the correct port (i.e. $PORT from the runtime environment).

I guess I need to change my approach and run my stubby4j application as a separate application ( as a core java app in cloud foundry ) that can be invoked from any cloudfoundry app

Sounds like you were already thinking about #1 above.