SuperPumpup (dot com)
General awesomeness may be found here.

08 December 2014

Packaging Up A Vert.X App

This is a work in progress... After @sigil66's tech talk at Boundary, I've been inspired to try to understand packaging and how to use packaging to deploy my software.

This is an application written in JRuby running on the Vert.X platform - so this will be an exploration around deploying a Vert.X application (which there is not a ton of documentation on, in any case...)

My Vagrantfile

I'm experimenting with all this on a Vagrant image - for now using Chef Server (on the OpsCode free plan). It's pretty vanilla, the only thing "fancy" at all would be mounting in my directory full of packages I've been building:

config.vm.synced_folder "#{ENV['HOME']}/code/obsidian-packages/", "/src/packages", :nfs => true

Package Vert.X

Run from the packages directory

This was done on my dev system - so Vert.X was installed at /Users/litch/bin/vert.x-2.1.2

$ fpm -s dir -t deb -n vertxpackages -a noarch \
  -C /Users/litch -f \
  ./bin/vert.x-2.1.2/sys-mods=/usr/share/vertx/ \
  ./bin/vert.x-2.1.2/conf/ \
  ./bin/vert.x-2.1.2/conf/ \
  ./code/UnlimitedJCEPolicyJDK8/US_export_policy.jar=/usr/lib/jvm/java-8-oracle-amd64/jre/lib/security/ \

Now, let's bundle up my app

Run from the packages directory

$ fpm -s dir -t deb -n backbone -a noarch -f -x "*.log" --deb-user vertx --deb-group vertx  -C ~/code/vertx-backbone .=/usr/local/backbone

And now let's package up the gems from RubyGems

First install JRuby on the build system:

$ curl | tar -zxC jruby --strip-components=1

$ export PATH=/opt/jruby/bin:$PATH

And package it:

$ fpm -s dir -t deb -n jruby -a noarch -C /opt/jruby -f .k=/opt/jruby

Run from the wherever, on the build machine with JRuby instaleld

$ mkdir /tmp/gems
$ gem install --no-ri --no-rdoc --install-dir /tmp/gems jruby-openssl
$ gem install --no-ri --no-rdoc --install-dir /tmp/gems sequel
$ gem install --no-ri --no-rdoc --install-dir /tmp/gems jdbc-postgres
$ gem install --no-ri --no-rdoc --install-dir /tmp/gems librato-metrics

$ find /tmp/gems/cache -name '*.gem' | xargs -rn1 fpm -f -d ruby -d rubygems --prefix /usr/local/backbone/gems -s gem -t deb

Note that this is all happening on a build machine with JRuby installed. The destination (production machine) will not have JRuby installed.

Packaging up one of my custom gems

$ fpm -d ruby --prefix /usr/local/backbone/gems -s gem -t deb /usr/local/backbone/gems/my-fanciness-0.1.0.gem

Now let's install all the gems

$ sudo dpkg -i /src/packages/rubygem*.deb

Launching the application

$ sudo -H -u vertx bash -c 'GEM_PATH=/usr/local/backbone/gems vertx run app.rb -cluster'

Concerns and Next Steps


  • Just dropping all of the packages into a linked "packages" directory isn't all the way there. Need to convert it to dropping them in a package repository. But I'm not sure how to do that yet.
  • The multi-step gems and application deployment is probably unnecessary. I can probably just keep the gems bundled in the application's gems directory.
  • I'm not sure what user to make the owner of the application files and the executor
  • I don't know what to do with log output (rsyslog?)

Next steps

  • Setting up a (runit) service to manage the application
  • Put the packages into an apt repo
  • Streamline the gem installation - I could probably do bundle install --local gems and then package that up
  • Automate this whole build system
  • Get the cluster.xml templated or whatever so that it works