• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby and Rails Packaging to Production
 

Ruby and Rails Packaging to Production

on

  • 6,741 views

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

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

Statistics

Views

Total Views
6,741
Views on SlideShare
6,674
Embed Views
67

Actions

Likes
7
Downloads
0
Comments
0

3 Embeds 67

http://en.oreilly.com 57
http://coderwall.com 9
http://elf.inroma.roma.it 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • infrastructure coding\n
  • \n
  • \n
  • \n
  • \n
  • NO! and yes. :-)\n**my** packages on **my** servers\nprivate repositories\n
  • \n
  • \n
  • multiple systems\nmultiple languages\nmultiple architectures\nsystem packages provide a lot of useful features\n
  • what is installed?\nwhat are the versions?\nwhat is the _current_ version of my app?\n
  • what are the config files?\nwhat is included?\n
  • what is the package of this file?\n
  • \n
  • \n
  • learning from operating systems, self-test boot\ndiff .example .conf\nexternal systems, api versions, required assets, filesystem, required users, fixtures, ...\nit’s all about dependencies! (other than package dependencies)\n
  • \n
  • bytecode precompilation\n
  • package => many projects\nsame package => many machines\nmultiple versions\n
  • \n
  • avoid compilation/build on production servers \ngcc, make, g++, libc-dev, etc\nrvm, git, ... the more crap you have in prod servers => the more to exploit\n\n
  • **same package** being deployed at different staging environments\n
  • \n
  • \n
  • \n
  • \n
  • pre/postrm\n
  • \n
  • rebuildable servers\nservers/machines as code\nrecreating machines => easy\n
  • what goes inside the package? what doesn’t?\n
  • \n
  • Configuration Managers\n
  • chef receipt\n
  • cf promisse\n
  • it belongs to your app => put it inside the package\nunless you expect it to be changed\nare people going to edit it after installing the package?\n
  • \n
  • deb, rpm offer easy ways to create them\n
  • as we are all doing\n
  • \n
  • \n
  • assets server\n
  • dh_make\ndebian/{control,rules,changelog}\ndpkg-buildpackage -> rules, sign\ndebian maintainers policy, ubuntu packaging guide\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • why things seem to be slower in the ruby vs system packages camp?\nwhy just a few people seems to be caring?\n
  • \n
  • \n
  • \n
  • rubygems, ruby and passenger debs\n
  • \n
  • tools\nnot usual to “build” stuff on production servers\nplatforms offer easy ways to make binary/system packages\nruby is probably missing that. Nobody is caring\n
  • \n
  • \n
  • \n
  • \n
  • other ideas:\n - rvm gemset package\n - rvm rubies package\n
  • \n
  • \n
  • \n
  • cloud IaaS and VMs help a lot\nbricklayer\nlaunchpad\nCI servers (hudson, bamboo, teamcity, ...)\n\n
  • - Watch git repositories\n- Build snapshots for each commit\n- Watch for tags testing_1.2.3 and stable_1.2.3\n- Promote packages to a ftp server (which runs reprepro or any other debian repository tool)\n- Has a rest API\n- Has cocoa-like web interface wrote with cappuccino framework\n- Batteries are included except redis server\n\n\n
  • \n
  • - Lauchpad generate binaries out of your source as long as your application is already ready to be packaged\n- Build packages for multiple archs\n- Host the package in a repository called PPA\n- Developed and open source by canonical\n
  • \n
  • \n

Ruby and Rails Packaging to Production Ruby and Rails Packaging to Production Presentation Transcript

  • packaging ruby and rails apps to production Fabio
Kung Rodrigo
Vaz
  • @fabiokung@rodrigovaz
  • no offense, but...
  • cap deploy
  • w"?
  •    
  • OMG... gem vs system pkgs again? disclaimer
  • it probably doesn’t apply to PaaS disclaimer
  • sysadmin love h+p://www.flickr.com/photos/theamarand/2879573829/
  • http://www.flickr.com/photos/sequelguy/4390001903/
  • sysadmins
and
sysops
know
OS/distro
tools http://www.flickr.com/photos/sequelguy/4390001903/
  • 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...
  • 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
  • dpkg -S /etc/myapp.conf $ dpkg -S /usr/bin/vim.basic vim: /usr/bin/vim.basic
  • 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
  • http://www.flickr.com/photos/atibens/4578265134/post install
  • health, sanity check
  • db/seeds.rb
  • rake db:migraterake assets:exportrake i18n:js:export ...
  • package repositories distribute it
  • signed packages
  • dev toolchain in production servers?
  • build pipeline
  • tes;ng
x
stable
  • multiple archs
  • dpkg -i myapp-oldversion
  • btw... rake db:migrate VERSION=old
  • dependencies
  • (re)deploying services must be ultra easy
  • package everything OH
WAIT...
  • configuration managers
  • recipes cf-agent promissescfengine, chef, rules cf-agent puppet cf-agent
  • 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
  • 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")}
  • rule of thumb
  • keysssh, access, crypt, passwords, ...
  • init scripts/etc/init.d/myapp start|stop|restart
  • configuration files <any>.yml.example
  • 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")
  • database.yml.example Chef,
Puppet production: adapter: mysql2 encoding: utf8 database: <%= db_name %> username: <%= db_user %> password: <%= db_password %> host: <%= db_address %>
  • packages are addictive
  • creating packages http://www.flickr.com/photos/miadcommunicationdesign/3169997945/
  • 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
  • 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
  • debian/rules               
  • dh_make --createorig
  • • dpkg-buildpackage• pbuilder• cowbuilder
  • why is it unusual?
  • debian-ruby- maintainersGiving up on Ruby packaging - Lucas Nussbaumhttp://www.lucas-nussbaum.net/blog/?p=617
  • 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
  • http://www.flickr.com/photos/brightbox/2298191057/
  • http://morethanseven.net/2011/01/16/Why-developers-should- care-about-system-packages.html Why Developers Should Care About System Packages -- Gareth Rushgrove
  • what about other platforms?
  • blaming gamewhat are we doing to end it?
  • github.com/locaweb/debundler
  • a long way to go...
  • RPM
  • bundle debianize (?) bundler deeper integration, plugin
  •            just some ideas... rvm is great :-)
  • vendor everything vs package everything gem dependencies
  • packaging gems• fpm• gem2deb• gem2rpm• checkinstall• debian/ changelog from git log
  • build servers
  • bricklayergithub.com/locaweb/bricklayer
  • 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"
  • launchpad dev.launchpad.net
  • pain points• old rubygems official system packages• bundler (!)• package yourself• PPA?
  • 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