So you have built your first awesome VoK app - congratulations! You will probably want to launch it outside of your IDE, or even deploy it somewhere on the interwebz. Just pick up any virtual server provider with your favourite Linux distribution.
There are following options to launch your app:
From Gradle, using the Gretty plugin
With proper configuration and
build.gradle file, you can simply use the Gretty Gradle plugin to launch wars. Gretty comes pre-configured in the sample quickstarter VoK HelloWorld App, so you can grab the Gradle configuration from there:
You can configure Gretty to launch your app either in Jetty or Tomcat, please read more here: http://akhikhl.github.io/gretty-doc/Gretty-configuration.html . To launch it in cloud, just ssh to your virtual server, install openjdk 8,
git clone your app to the server and run
From Docker, using the Tomcat image
Really easy - just head to the folder where your
my-fat-app-1.0-SNAPSHOT.war file is, and run the following line:
This command will start the Tomcat docker image and will mount your local folder with your war app into Tomcat's
webapps/ folder. Your app will then run at http://localhost:8080/my-fat-app-1.0-SNAPSHOT . To run at http://localhost:8080 just rename your war to
ROOT.war. To launch in your virtual server, just copy the WAR into your server, install docker and run the abovementioned command.
You can also create a Tomcat-based Docker image with your app easily. Just drop the following
Dockerfile next to your war file:
Then, just run this in the directory with the
Or even better, just use
Then all you need to run is just
--build will always rebuild the image so that you can play around with the
--force-recreate will delete old containers and create new ones so that Tomcat won't try to restore sessions from previous run).
It is possible to package Jetty or Tomcat into the WAR itself, add a launcher class and then simply run it via
java -jar your-app.war, thus making an executable WAR. You can read more about this option here: https://stackoverflow.com/questions/13333867/embed-tomcat-with-app-in-one-fat-jar . Unfortunately I have no experience in this regard.
Beware though: fat jars may not work for apps that package multiple files into the same location: for example there will be only one MANIFEST.MF. You can read about the pitfalls here: http://product.hubspot.com/blog/the-fault-in-our-jars-why-we-stopped-building-fat-jars
It is possible to embed Jetty - just check out this launcher class: https://github.com/mvysny/vaadin-on-kotlin/blob/master/vok-example-crud-jpa/src/test/kotlin/com/github/vok/example/crud/Server.kt