Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby and Rails Packaging to Production

11,548 views

Published on

Talk that I and Rodrigo vaz gave at RailsConf 2011: http://en.oreilly.com/rails2011/public/schedule/detail/19770

Published in: Technology
  • Be the first to comment

Ruby and Rails Packaging to Production

  1. packaging ruby and rails apps to production Fabio
Kung Rodrigo
Vaz
  2. @fabiokung@rodrigovaz
  3. no offense, but...
  4. cap deploy
  5. w"?
  6.    
  7. OMG... gem vs system pkgs again? disclaimer
  8. it probably doesn’t apply to PaaS disclaimer
  9. sysadmin love h+p://www.flickr.com/photos/theamarand/2879573829/
  10. http://www.flickr.com/photos/sequelguy/4390001903/
  11. sysadmins
and
sysops
know
OS/distro
tools http://www.flickr.com/photos/sequelguy/4390001903/
  12. dpkg -l$ dpkg -lii adduser 3.112ubuntu1ii apt 0.7.25.3ubuntu9.3ii apt-utils 0.7.25.3ubuntu9.3ii aptitude 0.4.11.11-1ubuntu10ii autoconf 2.65-3ubuntu1ii automake 1:1.11.1-1ii autotools-dev 20090611.1ii base-files 5.0.0ubuntu20.10.04.2ii base-passwd 3.5.22ii bash 4.1-2ubuntu3ii bash-completion 1:1.1-3ubuntu2ii binutils 2.20.1-3ubuntu7ii build-essential 11.4build1ii bzip2 1.0.5-4ubuntu0.1ii cdbs 0.4.62+nmu1ubuntu9ii cmake 2.8.1-4~lucid1ii cmake-data 2.8.1-4~lucid1ii coreutils 7.4-2ubuntu2ii cpp 4:4.4.3-1ubuntu1ii cpp-4.4 4.4.3-4ubuntu5ii cpu-checker 0.1-0ubuntu2ii cron 3.0pl1-106ubuntu5ii dash 0.5.5.1-3ubuntu2ii debconf 1.5.28ubuntu4ii debconf-i18n 1.5.28ubuntu4ii debhelper 7.4.15ubuntu1ii debianutils 3.2.2ii debootstrap 1.0.28ubuntu1~lucid1ii devscripts 2.10.61ubuntu5...
  13. dpkg -L myappdpkg --contents myapp.deb $ dpkg -L vim /. /usr /usr/bin /usr/bin/vim.basic /usr/share /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/vim /usr/share/bug /usr/share/bug/vim /usr/share/bug/vim/presubj /usr/share/doc /usr/share/doc/vim
  14. dpkg -S /etc/myapp.conf $ dpkg -S /usr/bin/vim.basic vim: /usr/bin/vim.basic
  15. apticron, cron-aptapticron report [Mon, 18 Apr 2011 18:25:02 -0300]=====================================================apticron has detected that some packages need upgrading on: foo.locaweb.com.br [ 10.0.0.1 ]The following packages are currently pending an upgrade: myapp 5.1.0-3 myapp-assets 5.1.0-3======================================================Package Details:Reading changelogs...--- Changes for myapp (myapp myapp-assets) ---myapp (5.1.0-3) stable; urgency=low * new awesome feature * lots of bug fixes-- Fabio Kung <fabio.kung@locaweb.com.br>  Tue, 12 Apr 2011 22:31:11 -0300
  16. http://www.flickr.com/photos/atibens/4578265134/post install
  17. health, sanity check
  18. db/seeds.rb
  19. rake db:migraterake assets:exportrake i18n:js:export ...
  20. package repositories distribute it
  21. signed packages
  22. dev toolchain in production servers?
  23. build pipeline
  24. tes;ng
x
stable
  25. multiple archs
  26. dpkg -i myapp-oldversion
  27. btw... rake db:migrate VERSION=old
  28. dependencies
  29. (re)deploying services must be ultra easy
  30. package everything OH
WAIT...
  31. configuration managers
  32. recipes cf-agent promissescfengine, chef, rules cf-agent puppet cf-agent
  33. package "sudo" do  action :upgradeenduser "sshservice" do  system true  action :createendtemplate "/etc/sudoers" do  source "sudoers.erb"  mode 0440  owner "root"  group "root"  variables(:user => "sshservice")  action :createend
  34. bundle common control{    bundlesequence => { "ssh" };    inputs => { "cfengine_stdlib.cf" }}bundle agent ssh{    packages:        "sudo"            package_policy => "add"            package_method => "deb"    files:        "/etc/sudoers"            edit_defaults => empty,            edit_line => expand_template("sudoers.in"),            perms => mog("0440", root, root),            create => "true";    methods:        "sshservice" usebundle => create_user("sshservice")}
  35. rule of thumb
  36. keysssh, access, crypt, passwords, ...
  37. init scripts/etc/init.d/myapp start|stop|restart
  38. configuration files <any>.yml.example
  39. database.yml.example CFEngine3 production: adapter: mysql2 encoding: utf8 database: ${db_name} username: ${db_user} password: ${db_password} host: ${db_address}edit_line => expand_template("database.yml.example")
  40. database.yml.example Chef,
Puppet production: adapter: mysql2 encoding: utf8 database: <%= db_name %> username: <%= db_user %> password: <%= db_password %> host: <%= db_address %>
  41. packages are addictive
  42. creating packages http://www.flickr.com/photos/miadcommunicationdesign/3169997945/
  43. debian/controlSource: myappSection: webPriority: extraMaintainer: Fabio Kung <fabio.kung@locaweb.com.br>Build-Depends: debhelper (>= 7)Standards-Version: 3.8.3Homepage: https://github.com/locaweb/myappPackage: myappArchitecture: anyDepends: rubygems (>= 1.3.6), libapache2-mod-passenger (>= 2.2)Description: my great new app Visit https://mycompany.com/myapp for more information
  44. debian/changelogmyapp (0.0.2) unstable; urgency=low * Applying SOLID after attending railsconf 2011 * using Devise-- Fabio Kung <fabiokung@locaweb.com.br> Wed, 18 May 2011 08:00:30 -0300myapp (0.0.1) unstable; urgency=low * Initial release-- Rodrigo Vaz <rodvaz@locaweb.com.br> Wed, 17 May 2011 18:05:20 -0300
  45. debian/rules               
  46. dh_make --createorig
  47. • dpkg-buildpackage• pbuilder• cowbuilder
  48. why is it unusual?
  49. debian-ruby- maintainersGiving up on Ruby packaging - Lucas Nussbaumhttp://www.lucas-nussbaum.net/blog/?p=617
  50. FPM awesome https://github.com/jordansissel/fpmI
want
a
simple
way
to
create
packages
without
all
the
bullshit.
In
my
own
infrastructure,
I
have
no
interest
in
Debian
policy
and
RedHat
packaging
guidelines
‐
I
have
interest
in
my
groups
own
style
culture
and
have
a
very
strong
interest
in
ge6ng
work
done. ‐‐
Jordan
Sissel
  51. http://www.flickr.com/photos/brightbox/2298191057/
  52. http://morethanseven.net/2011/01/16/Why-developers-should- care-about-system-packages.html Why Developers Should Care About System Packages -- Gareth Rushgrove
  53. what about other platforms?
  54. blaming gamewhat are we doing to end it?
  55. github.com/locaweb/debundler
  56. a long way to go...
  57. RPM
  58. bundle debianize (?) bundler deeper integration, plugin
  59.            just some ideas... rvm is great :-)
  60. vendor everything vs package everything gem dependencies
  61. packaging gems• fpm• gem2deb• gem2rpm• checkinstall• debian/ changelog from git log
  62. build servers
  63. bricklayergithub.com/locaweb/bricklayer
  64. REST APIPOST /project: name="myapp" version="1.0.1" git_url="git://host/project/repository.git" branch="master" build_cmd="rake prepare" install_cmd="rake install PREFIX=debian/tmp" respository_url="ftp.location.com" repository_user="a_user" repository_passwd="a_g00dP455w0rd"
  65. launchpad dev.launchpad.net
  66. pain points• old rubygems official system packages• bundler (!)• package yourself• PPA?
  67. Thanks! fabio.kung at gmail, @fabiokung rodrigo.vaz at gmail, @rodrigovaz additional info: https://wiki.ubuntu.com/PackagingGuidehttp://morethanseven.net/2011/01/16/Why-developers-should-care-about-system-packages.html https://github.com/jordansissel/fpm http://www.lucas-nussbaum.net/blog/?p=617

×