JRuby with Sinatra on Heroku Skeleton
This is a bare bones sinatra app skeleton which will enable you to deploy JRuby apps using sinatra to Heroku.
Heroku has supported Java for a little while now but documentation and how-to's are scant about deployment.
I've personally tested this in September 2012 with JRuby 188.8.131.52 and it works fine.
I've included .rvmrc and selected trinidad as the application server.
Install and configure RVM with jruby-1.6.7.
Check this code out from github.
$ git clone git://github.com/rpocklin/jruby-sinatra-heroku-skeleton.git
Run a script (for the lazy) which will do all the following for you.
If you want to do it manually (or find out what it does...)
Go into the project directory and run:
$ jruby -S gem install bundler heroku
Edit your Gemfile to update whatever you want in there.
Generate your Gemfile.lock and load dependencies:
$ jruby -S bundle install
Duplicate the Gemfile to Jemfile so that heroku knows its a JRuby app.
$ cp Gemfile Jemfile $ cp Gemfile.lock Jemfile.lock
$ git init $ git add . $ git commit -m "Initial commit of repository"
Initialise and push to Heroku (with cedar stack for java) this will give you the application URL (can be renamed by logging in to heroku.com)
$ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-java.git $ git push heroku master
View the install logs
$ heroku logs
or to tail the logs in production:
$ heroku logs --tail
Test it responds correctly:
$ curl http://your_app.heroku.com/
You should get 'Waiting for an awesome API to be written... please come back later' and your done!
Note: The example.rb file should be renamed/replaced with your own specific application code, and use server.rb for your sinatra routes.