pkgr: apt-get install my-rails-app

2c7e548d5728c041c6ceda3c97548664?s=47 crohr
June 23, 2012

pkgr: apt-get install my-rails-app

Lightning talk about the pkgr gem, which is a tool to build debian packages out of Rails3 apps (given at #rulu 2012).

2c7e548d5728c041c6ceda3c97548664?s=128

crohr

June 23, 2012
Tweet

Transcript

  1. pkgr apt-get install my-rails-app

  2. Ruby & Node.js developer (freelance, in Rennes) RuLu Ticket #001

    @crohr http://crohr.me Who? Cyril Rohr 2
  3. •PaaS (Heroku, Red Hat Openshift, etc.) is great •Capistrano is

    great Deploying Rails apps
  4. The problem • Not everyone is willing to use PaaS

    (i.e. stick with Plain Old EC2, VPS, etc.) • Not everyone is willing to endure a Capistrano based workflow (RVM?, passenger?, rubygems?, bundler?, before/ after_hooks...) => not a reliable nor straightforward process. • Willing to better integrate your app deployment process with infrastructure automation tools (Puppet/Chef): package {"my-rails-app": ensure => installed } (better use your native OS’s package manager to deploy your app)
  5. What if? apt-get install my-rails-app (debian packages made easy)

  6. What if? apt-get install my-rails-app (debian packages made easy) not

    endorsed by the debian community
  7. pkgr • http://crohr.me/pkgr/ • Automatically builds a debian package out

    of a Rails3 app. Self-contained app + app server (thin) • Uses system ruby, so that you get the security updates • Bundles everything else inside the package (avoids library dependency hell with other apps/system gems), even bundler.
  8. How does it work? •$ gem install pkgr •$ rails

    new my-rails-app •$ cd my-rails-app && git init •$ git add . && git commit -m “All in”
  9. How does it work? • Have a build VM ready

    with the target OS (use Vagrant, or EC2 VM) •$ pkgr --uri . --bump 0.1.0 \ --host debian-build-machine [...] my-rails-app_0.1.0-1_amd64.deb
  10. Generated files --- version: 0.1.0 name: my-rails-app description: git_ref: pkgr-master

    config_files: - pkgr.yml - database.yml architecture: amd64 debian_runtime_dependencies: - ${shlibs:Depends} - ${misc:Depends} - ruby1.9.1-full - git-core - libxml2 - libxslt1.1 debian_build_dependencies: - debhelper (>= 7) - dpkg-dev - libmysqlclient15-dev - libxml2-dev - libxslt-dev - libsqlite3-dev config/pkgr.yml debian/ (can be modified afterwards)
  11. Deployment • Push to an APT repository (recommended) prod-server #

    cat /etc/apt/sources.list.d/my-rails-app.list deb http://apt-server.ltd/my-rails-app / prod-server # apt-get update && apt-get install my-rails-app • Or just upload it manually on your servers prod-server # dpkg -i my-rails-app_0.1.0-1_amd64.deb /etc/init.d/my-rails-app start|stop|restart my-rails-app rake ... my-rails-app console For free:
  12. Notes of interest • Configuration files will be stored in

    /etc/my-rails-app/*.yml • Change how the app server is launched by adding options to /etc/default/my-rails-app • Log files will be stored in /var/log/my-rails-app/ • Db files (if any) will be stored in /var/db/my-rails-app/
  13. Advanced • Deploy from a git repository; add additional configuration

    files: pkgr --uri https://github.com/edavis10/redmine --ref master --bump 1.4.1 \ -c https://raw.github.com/crohr/pkgr/master/examples/redmine/configuration.yml \ -c https://raw.github.com/crohr/pkgr/master/examples/redmine/database.yml \ -c https://raw.github.com/crohr/pkgr/master/examples/redmine/pkgr.yml \ --host debian-build => this example packages the latest Redmine version (instead of the offical package, still based on Rails2.3).
  14. Thanks http://crohr.me/pkgr