In this tutorial, I will guide you through setting up a working instance of a Spring Boot application on Pivotal Cloud Foundry. It was inspired by a tutorial I read, explaining how to deploy a Spring Boot app on OpenShift 3. While the article is well written, I couldn’t get over the fact that it requires a lot of boilerplate steps and configuration just to get a hello world up and running, so I thought I’ll clarify how simple it is on the other side of the fence.
Prepare a Spring Boot app
To deploy a Spring Boot application you need to have a compiled jarfile.
As an example we can clone spring-boot-docker sample project. In the “complete” folder, you can build the project:
cd complete ./mvnw clean package
Make sure you have setup a free trial account with Pivotal Web Services at run.pivotal.io. You have a 2gb ram limit and your application will not be shut down during the trial
- login to your PCF Cluster:
iMac5k:~ demo$ cf login -a api.run.pivotal.io
2. Run the cf push command:
iMac5k:target demo$ cf push spring-boot-docker-0.1.0 -p gs-spring-boot-docker-0.1.0.jar
You can check the app is running by going to https://spring-boot-docker-010.cfapps.io. Notice the application is protected by SSL/TLS by default:
That’s it, we’re done! If you want to learn about viewing your application in PWS apps manager, click here.
In this tutorial, I explained how to deploy a Spring boot application to Pivotal Cloud Foundry. I hope you found it useful, educating, and (hopefully…) amusing ;)
Good luck, and happy coding!