Be able to run Java App on top of EC2 with OSv ( as minimalistic operating system as possible ) . Create AMI with custom jar and start application once machine is up.
Using Capstan should be way to go, create new image, test it on QEMU or Virtual Box and once ready produce EC2 image. That path didn’t go well for me, I had issues installing Capstan, running sample image initially on Mac and later trying on EC2.
Instead I went in different direction, used one of already available OSv AMIs. I used OSv-Tomcat to ensure I have Java ready. OSv comes with Java 1.7. EC2 instance used was m3.medium. I was unable to get dashboard running on m4.medium. Easiest way to ensure instance is up and ready is to check Dashboard running on 8000. Make sure port 8000 is allowed in Security Group ( for my HTTP server I also used additional 7071 port ). Tomcat which is started out of box is running on 8081.
Next step is customization. For all required steps Dashboard REST API was enough. Create uber jar of custom http server, I was using simple-http-server given in links, running mvn clean package. Upload uber jar over Dashboard REST File API.
Use Dashboard REST OS API to change startup command, original command was
java.so io.osv.MultiJarLoader -mains /etc/javamains
to ( http server uber jar is named app.jar on OSv FS )
java.so -jar app.jar
Use Dashboard REST OS API to restart OS. Once OS is restarted custom http server should be available on 7071 port.
Hello World on: /test.
Create AMI from EC2 EBS volume and use it to spin tons of simple http servers 🙂