Web applications written in Ruby on Rails framework usually have a long list of dependencies. In addition to ruby gem dependencies, they also have javascript/nodejs dependencies for front end.

Note: The same workflow can be used for other web apps as well.

There are three approaches to packaging a ruby on rails web app.

  1. First approach is the traditional approach of packaging all dependencies separately. redmine, gitlab and diaspora packages follow this approach.
  2. Second approach is using bundle install to fetch all the dependencies in postinst script. diaspora-installer is following this approach
  3. Third approach is following a mixed appraoch were already packaged gems are used where possible and remaining gems are pulled from rubygems.org

Step by Step Guide

  1. Download tar.gz from tags or use git snapshot
  2. Use debmake to create initial packaging
  3. Create initial install files from ls -1 (remove debian, install to /usr/share/<appname>)

  4. bundle install (set path to vendor/bundle or pick native gems from system as required). This will need adjusting Gemfile.lock if packaged native gem versions differ and mixed strategy is followed. For traditional approach, Gemfile is patched as required and Gemfile.lock is generated with bundle install --local
  5. Configure database with dbconfig-common and initialize database in postinst (use rake db:migrate for updates if the db is not empty)
  6. Precompile assets (use webpack if required)
  7. Configure application server (puma or unicorn) and configure init script or systemd unit files to start automatically.
  8. Configure nginx/other http servers on localhost (use debconf to ask for hostname)
  9. Setup https with certbot (ask using debconf templates to enable or disable this)

Dependency Tracker

We can create a dependency tracker using https://gitlab.com/debian-ruby/gemdeps-generator/ It looks at each dependency in Gemfile and compare with the packaged versions and provide a table or task list to make updating dependencies easier.

Currently Packaged rails apps

  1. Diaspora

  2. gitlab

  3. pupilfirst