Montag, 23. Juli 2007

Capistrano 2.0 is real

Great news. Your favourite tool for automating tasks on multiple machines has released his second version. It is really an awesome tool. It makes you forget physical boundries between systems. Deploying is no pain anymore since capistrano does anything for us.

Labels: , ,

Donnerstag, 24. Mai 2007

Deploying with capistrano - The copy method

Capistrano is a great tool for automating tasks on remote machines. In this article i will show you howto update a static webpage where the server has no svn installed. The only things you need are: a local ruby, rubygems and capistrano installation and ssh access to the remote webserver where the files should deployed to.
You need capistrano 2.0 or 2.0 preview, install the preview with:
gem install net-ssh
gem install net-sftp
gem install highline
gem install -s http://gems.rubyonrails.com capistrano
Similar to make's Makefile's capistrano uses Capfile's. To create a Capfile in the current directory execute:
capify .
Now you can edit the Capfile to fit your deployment needs:
require 'capistrano/version'
# Load the deployment recipe
load 'deploy'
# Give a name for your application
set :application, :website
# Define a server role
role :server, 'yourhomepage.com'
# Define where to store the deployed files
set :deploy_to, '/hp/aa/ab/ne'
# Define where to create the symlink to the current release, normally
# this would be your htdocs or www directory
set :current_path, '/hp/aa/ab/ne/www'
# Define that we want to deploy via copy, this is usefull if your server
# has no subversion client installed
set :deploy_via, 'copy'
# Set the deploy strategy to export, otherwise the files are checked out
# from your repository
set :copy_strategy, :export
# Set your ssh user name and password
# (If you omit the password and did not have setup public key authentication,
# capistrano will prompt you for the password)
set :user, 'your-ssh-username'
set :password, your-ssh-password'
# Set the project repository. All files inside the specified directory
# will deployed.
set :repository, 'file:///repositories/website/public'

# Override tasks not needed for deployment of static files
namespace :deploy do
task :finalize_update do
logger.info 'do nothing - overridden finalize_update'
end
task :restart do
logger.info 'do nothing - overridden finalize_update'
end
end
Thats it, now you can setup your host for deployment with(First you need to go into the directory where your Capfile is stored):
cap deploy:setup
And deploy with:
cap deploy
You will find many default setting in: lib/capistrano/recipes/deploy.rb.

Labels: , ,