Upgrade to Pro — share decks privately, control downloads, hide ads and more …

pkgr: apt-get install my-rails-app

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).

crohr

June 23, 2012
Tweet

More Decks by crohr

Other Decks in Programming

Transcript

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

    @crohr http://crohr.me Who? Cyril Rohr 2
  2. 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)
  3. 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.
  4. 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”
  5. 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
  6. 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)
  7. 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:
  8. 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/
  9. 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).