Capistrano is a remote multi-server automation tool.
Developed and tested for Ubuntu 12.04
-
base contains the task to which all other reciepes hook in. Also installs some software dependencies
-
check makes sure the local GIT repo is in sync with the remote repo before the code is deployed
-
figaro symlinks your custom
application.yml
file for Figaro -
foreman controlls the app server via foreman.
-
nginx installs, configures and controls nginx. (Installed from ppa:nginx/stable)
-
mongodb installs, configures and controls mongodb (Installed from the 10gen repos)
-
mongoid symlinks your custom
mongoid.yml
file for Mongoid -
nodejs installs node.js from ppa:chris-lea/node.js
-
postgresql installs, configures and controls PostgreSQL. Also installs the dependencies for the pg gem.
-
rbenv installs rbenv, ruby-build, rbenv-gemset (if configured) and the dependencies to build Ruby.
-
unicorn installs, configures and controls unicorn
Install the recipes:
git submodule add git@github.com:mhutter/capistrano-recipes.git config/recipes
Set up your deploy.rb
according to this example:
require "bundler/capistrano"
load "config/recipes/base"
# below here, comment out the ones you don't need
load "config/recipes/check"
# load "config/recipes/custom_config"
load "config/recipes/figaro"
load "config/recipes/foreman"
load "config/recipes/mongodb"
load "config/recipes/mongoid"
# load "config/recipes/newrelic"
# load "config/recipes/newrelic_sysmond"
load "config/recipes/nginx"
# load "config/recipes/nodejs"
# load "config/recipes/postgresql"
load "config/recipes/rbenv"
# load "config/recipes/unicorn"
load "config/recipes/uploads"
server "ip.or.hostname", :web, :app, :db, primary: true
set :application, "app_name" # configure at least THIS...
set :domain, "#{application}.com"
set :user, "deployer" # ...THIS...
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false # this may be a bit misleading, the user on the server still needs sudo-rights!
set :scm, :git
set :repository, "git@github.com:your_github_account/#{application}.git" # ...and THIS.
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:migrate"
after "deploy", "deploy:cleanup" # last 5 releases
# and maybe some of THIS
# set :ruby_version, "2.0.0-p247" # default 2.0.0-p247
# set :use_rmagick, true # default false
# set :use_rbenv_gemset, true # default false
# set :newrelic_key, "???" # required for `newrelic` and `newrelic_sysmond`
For configuration options on specific recipes, see the set_default
statements in the according source files.
You can find this deploy.rb
file in the example/
subdirectory.