Deploy Java and JVM-Based apps using OpsCaptain
OpsCaptain can deploy Java, Scala and any JVM-Based language and framework. Under the hood, the platform uses the Cloud Foundry battle
tested open source java buildpack.
From the developers perspective, you simply deploy your code using the CLI and OpsCaptain configures the environment to compile
your application using the java buildpack. Knowledge of Cloud Foundry is not required nor do you need to know how the buildpack
works unless you want to customize the runtime parameters used to build your application. Click on the buildpack link to learn about how to do this. OpsCaptain provides a Cloud Foundry compatible environment on your own
servers so you can run your JVM applications.
Install the opscaptain-cli on your local machine and also log in. If you haven't, run the below commands from your terminal to install it and login:
npm install -g opscaptain-cli
opscaptain login -em email@example.com -pw ******
You must have already added the server that will be used to host your Java app. To add a server to your OpsCaptain account,
follow this guide here.
If you do not have a server yet, you can purchase a server or use the free tier or credit from one of the following clouds: AWS EC2,
Microsoft Azure, Vultr, DigitalOcean
Step 1. Create your app
From the dashboard: Log into the dashboard and create a new app using this link.
Select the required database engine. If your app does not require a database, do not make a selection. Once the app and database are created, you can then proceed to deploy your code to it.
Step 2. Create the ocmanifest.json file in your application directory.
You will typically configure the ocmanifest.json file on your first deployment or when you need to change any environment variables.
The below example shows a sample ocmanifest.json file to deploy Java apps:
// The name you provided when creating the app in step 1
// Configure environment variables if any
Step 3. Deploy your Jar, War, Dist zip build output
With the exception of Groovy apps which can be deployed as is, you have to first build your application and then push the build output.
Before you run any of the example commands given below, CD to the directory of your project folder. 😃
Example deploying Grails
// Build the application into a .war file
// Deploy the .war file to your server.
opscaptain deploy -p target/grails-application-0.1.war
Example deploying Groovy
The Java Buildpack can run Groovy applications written with the Ratpack framework and from raw .groovy files (no pre-compilation).
Example deploying Java Main
The Java Buildpack can run Java applications with a main() method provided that they are packaged as self-executable JARs
// building with Gradle example:
// Or building with Maven example:
// Finally deploy the JAR to your server and run it:
opscaptain deploy -p target/java-main-application-1.0.0.BUILD-SNAPSHOT.jar
Example deploying Play framework
// bundle using play dist and deploy
opscaptain deploy -p target/universal/play-application-1.0-SNAPSHOT.zip
// bundle using play stage and deploy
opscaptain deploy -p target/universal/stage
Example deploying Servlet packaged as a WAR file
opscaptain deploy -p build/libs/web-servlet-2-application-1.0.0.BUILD-SNAPSHOT.war
Example deploying Spring Boot CLI
// using spring grab
spring grab *.groovy
// using spring jar
spring jar spring-boot-cli-application-1.0.0.BUILD-SNAPSHOT.jar *.groovy
opscaptain deploy -p spring-boot-cli-application-1.0.0.BUILD-SNAPSHOT.jar