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

A Continuous Packaging Pipeline

A Continuous Packaging Pipeline

Maciej Pasternacki

February 02, 2013
Tweet

More Decks by Maciej Pasternacki

Other Decks in Programming

Transcript

  1. – Nginx is too old – I need Node.js –

    I need foo.jar on all application servers – A Java VM would help using it… Web infrastructure problems
  2. – Nginx is too old – I need Node.js –

    I need foo.jar on all application servers – A Java VM would help using it… }Compiling on server is WRONG Web infrastructure problems
  3. Goals – Single repository for all packages Actually, why not

    chef-repo? – One directory per package – Share package definitions between projects – Run various build systems
  4. Vendorificator archive 'hello', :version => '2.8', :url => "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz" git

    'git://github.com/octocat/Hello-World.git' Integrate upstream modules in a Git repository https://github.com/3ofcoins/vendorificator/
  5. Vendorificator archive 'hello', :version => '2.8', :url => "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz" git

    'git://github.com/octocat/Hello-World.git' https://github.com/3ofcoins/vendorificator/
  6. Vendorificator – Share package definitions between projects – Include packages’

    original sources in the repository https://github.com/3ofcoins/vendorificator/
  7. Metarake A Rake extension that: 1.Discovers modules and their build

    targets 2.Builds modules with unpublished targets 3.Publishes the built targets https://github.com/3ofcoins/metarake/
  8. Metarake It’s used to: 1.Find */Rakefile and their *.deb targets

    2.Build packages not in the apt repo 3.Push built packages into the apt repo https://github.com/3ofcoins/metarake/
  9. Metarake https://github.com/3ofcoins/metarake/ require 'metarake' require 'metarake/publisher/freight' class PackagesMetaTask < MetaRake::Task

    include MetaRake::Builder::Rake include MetaRake::Publisher::Freight self.target_filter = /\.deb$/ self.rake_command = 'fakeroot bundle exec rake' self.freight_distro = 'squeeze' self.freight_conf_path = 'freight.conf' end task :default => PackagesMetaTask.discover!
  10. Evoker https://github.com/3ofcoins/evoker/ An add-on to Rake to download and manage

    external dependencies of a project, patch or modify them as needed, cache them, etc.
  11. Evoker https://github.com/3ofcoins/evoker/ tarball('swftools', :url => 'http://www.swftools.org/swftools-0.9.1.tar.gz') patch 'swftools', 'swftools-Makefile_hack.patch', '-p1'

    if linux? task 'swftools' => [ :python, 'swftools_pyconfig.py' ] do sh <<-EOF set -e -x cd swftools eval `../python/bin/python ../swftools_pyconfig.py` ./configure make EOF end
  12. FPM – Create, convert, modify packages – Sources: gem (Ruby),

    pypi (Python), pear (PHP), npm (Node.js), rpm, deb, directory – Targets: deb, rpm, solaris, tar, directory https://github.com/jordansissel/fpm/
  13. FPM $ fpm -s dir -t deb \ -n jenkins

    -v 1.396 \ --prefix /opt/jenkins jenkins.war https://github.com/jordansissel/fpm/
  14. FPM $ fpm -s dir -t deb \ -n jenkins

    -v 1.396 \ --prefix /opt/jenkins jenkins.war $ fpm -s gem -t deb json # rubygem-json-1.4.6-1.amd64.deb https://github.com/jordansissel/fpm/
  15. FPM $ ./configure --prefix=/usr \ && make \ && make

    install DESTDIR=$ROOT $ fpm -s dir -t deb -n foo -v 0.1 \ -d "libssl0.9.8 (> 0)" \ -C $ROOT . https://github.com/jordansissel/fpm/
  16. Freight https://github.com/rcrowley/freight $ freight add foo_0.0.1-1_all.deb \ apt/lucid apt/precise $

    freight cache apt/lucid apt/precise “A modern take on the Debian archive”
  17. Example PKG_NAME = 'nodejs' PKG_DESCRIPTION = 'Node.js' PKG_VERSION = '0.8.17'

    PKG_ITERATION = 'local1' PKG_ARCH = 'amd64' PKG_DEB_FILE = "#{PKG_NAME}_#{PKG_VERSION}-#{PKG_ITERATION}_#{PKG_ARCH}.deb" SRCDIR = "node-v#{PKG_VERSION}" TARBALL = "#{SRCDIR}.tar.gz" URL = "http://nodejs.org/dist/v#{PKG_VERSION}/#{TARBALL}" CHECKSUM = '8f070b42ffb84fde9d3ed2f802b08664b94dda327a36bf08…' BUILT = "#{SRCDIR}/out/Release/node" INSTALL_ROOT = File.expand_path('__install_root__') INSTALLED = "#{INSTALL_ROOT}/opt/node/bin/node"
  18. Example file BUILT => tarball do rm_rf SRCDIR sh "tar

    -xzf #{tarball}" chdir SRCDIR do sh "./configure --prefix=/opt/node" sh "make" end end file INSTALLED => BUILT do rm_rf INSTALL_ROOT chdir(SRCDIR) { sh "make install DESTDIR=#{INSTALL_ROOT}" } end
  19. Example desc "Build the package" file PKG_DEB_FILE => INSTALLED do

    sh <<EOF fpm -s dir -t deb -C #{INSTALL_ROOT} \\ --license 'All rights reserved' --vendor 'Ourselves' \\ --name #{PKG_NAME} --version #{PKG_VERSION} \\ --iteration #{PKG_ITERATION} --architecture #{PKG_ARCH} \\ --description '#{PKG_DESCRIPTION}' \\ . EOF end task :default => PKG_DEB_FILE