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-sshSimilar to make's Makefile's capistrano uses Capfile's. To create a Capfile in the current directory execute:
gem install net-sftp
gem install highline
gem install -s http://gems.rubyonrails.com capistrano
capify .Now you can edit the Capfile to fit your deployment needs:
require 'capistrano/version'Thats it, now you can setup your host for deployment with(First you need to go into the directory where your Capfile is stored):
# 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
cap deploy:setupAnd deploy with:
cap deployYou will find many default setting in: lib/capistrano/recipes/deploy.rb.
Labels: automation, capistrano, deploy

0 Kommentare:
Kommentar veröffentlichen
Links zu diesem Post:
Link erstellen
<< Startseite