Slide 1

Slide 1 text

pkgr apt-get install my-rails-app

Slide 2

Slide 2 text

Ruby & Node.js developer (freelance, in Rennes) RuLu Ticket #001 @crohr http://crohr.me Who? Cyril Rohr 2

Slide 3

Slide 3 text

•PaaS (Heroku, Red Hat Openshift, etc.) is great •Capistrano is great Deploying Rails apps

Slide 4

Slide 4 text

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)

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

What if? apt-get install my-rails-app (debian packages made easy) not endorsed by the debian community

Slide 7

Slide 7 text

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.

Slide 8

Slide 8 text

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”

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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)

Slide 11

Slide 11 text

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:

Slide 12

Slide 12 text

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/

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Thanks http://crohr.me/pkgr