Distributed building tool, originally inspired by Python's Parcel, just written in Ruby and with many improvements. Parcel is taking advantage of Capistrano 3, SSHkit and FPM.
The idea is simple:
- we want to deploy native packages packed with all dependencies
- support multiple releases/distribution
- fast and reliable deployment
- updating N production servers with
git pull
+ package dependencies doesn't scale well - package should be tested before going to production
Project structure looks like this:
├── lib
├── config
│ ├── deploy
│ │ ├── build.rb
│ │ ├── production.rb
│ │ └── staging.rb
│ └── deploy.rb
├── Capfile
├── Gemfile
├── Gemfile.lock
In Capfile
we specify which plugins should be used during package making process.
Capfile: (note: we're not using standard Capistrano deploy
task)
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/parcel'
# build package with fpm
require 'capistrano/parcel/fpm'
Basic scenario expects few categories of servers:
- build - for each distribution you can have one
- staging
- production
For each category you can you different settings (ssh keys, user account, etc.)
This will build package on remote server and transfer package back to your machnine (over scp
)
$ cap build parcel
Each phase is a separate Rake task. You can use before
and after
hooks to execute any code before/after.
- starting
- updating
- compiling
- packaging
- finishing
Rsync is used for copying files to build server. This way we can easily copy a git repository with submodules.
You can control which files will be packaged with
set :rsync_exclude, [ '.git', 'some-other-dir' ]
Plugins are usually simple tasks that are executed in several steps during building process. Plugins can't rely on each other, rather use variables, that are accessible with set(:var)
and for reading fetch(:var)
.
Each plugin can be enabled in Capfile
:
require 'capistrano/parcel/plugin_name'
Used for packaging whole directory as a deb package. Could be used also for RPM or other packages.
Simple application server configuration.
Enable with:
require 'capistrano/parcel/uwsgi'
Currently allows only intialization of nginx scripts.
Enable with:
require 'capistrano/parcel/nginx'
(experimental)
(experimental)
Meta information about package is fetched from a package.yml
file which must be located on local filesystem (in directory where is cap
command executed).
version: '0.0.1'
arch: 'all'
license: 'MIT'
category: 'misc'
maintainer: '[email protected]'
vendor: 'Jon Doe et al.'
description: 'Package description'
url: 'http://example.com'
requirements:
- some version of Ruby (> 1.8.7 is recommended)
- Bundler (
gem install bundler
)
Create a Gemfile
with following content:
source 'https://rubygems.org'
gem 'capistrano-parcel', github: 'deric/capistrano-parcel'
and run bundle install