Capistrano

Capistrano is deploy tool using Ruby.

Install Capistrano

Do you have Ruby? (>=1.9). That’s fine!

sudo gem install capistrano

Get Started test project

Let’s make test project and setting files

mkdir test
cd test
cap install

You can see config/deploy.rb, config/deploy/stating.rb, config/deploy/production.rb.
Files

  • config/deploy.rb : Common settings and steps
  • config/deploy/staging.rb : Staging setting and tasks

staging is prod, dev, test, etc… steps env.

Common setting file(config/deploy.rb)

What kind of things does deploy.rb do?

  • Get source codes(git etc…)
  • Build, archive, create package
  • Install, start application etc…

config/deploy.rb

  • Application name
  • Repository
  • Task
  • Task command

Default task

framework_tasks

Target(staging) setting

server

Server settings

  • hostname
  • server role
  • login user
  • ssh
  • others

Example

server 'localhost', user:'tomcat',roles: %w{web}

server hostname, user: username, roles: %{serverrole}

Run cap command

Run capistrano

cap staging deploy

This is example of staging. Target is config/deploy/staging.rb
Task is deploy