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.
- First approach is the traditional approach of packaging all dependencies separately. redmine, gitlab and diaspora packages follow this approach.
- Second approach is using bundle install to fetch all the dependencies in postinst script. diaspora-installer is following this approach
- 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
- Download tar.gz from tags or use git snapshot
- Use debmake to create initial packaging
Create initial install files from ls -1 (remove debian, install to /usr/share/<appname>)
- 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
- Configure database with dbconfig-common and initialize database in postinst (use rake db:migrate for updates if the db is not empty)
- Precompile assets (use webpack if required)
- Configure application server (puma or unicorn) and configure init script or systemd unit files to start automatically.
- Configure nginx/other http servers on localhost (use debconf to ask for hostname)
- Setup https with certbot (ask using debconf templates to enable or disable this)
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.