Version 10, last updated by Rob Chekaluk at February 18, 2010 11:16 UTC
Deploying with Capistrano
Deploying with Capistrano
The Assembla Build Agent currently uses Capistrano for deployment. Here are steps to configure an application for deploying with Capistrano and Build Tool:
- Capify your project
- Set your Capistrano configuration variables in config/deploy.rb:
- host – set to “localhost”, otherwise the system will try to deploy your application to another server.
- user – set to the login of the user that will run the build (our preconfigured images have a “deploy” userid for this purpose)
-
repository – set to the address of the repository containing application sources (eg.
set :repository, "git://git.assembla.com/myspace.git") - application – set to the application name
- scm – possible values are :git or :svn
-
deploy_to – set to the path where the application should be deployed to (remember that deploy user should have write permission to this folder). By default Capistrano will deploy to
/u/apps/#{application}, however our implementation deploys to/opt/apps. - use_sudo – you may need to set this to false
- app, web, db – You may also need to add the hostname of your build server to these or other role statements.
Some Capistrano configuration variables can be retrieved from the environment; just remember to load the configuration file of the project before this in the script that will run Capistrano tasks:
- repository –
set :repository, ENV['SCM_URL'] - application –
set :application, ENV['PROJECT_NAME'] - scm –
set :repository, ENV['SCM']
If you want to use same Capistrano config for stage and for production by example, where you may have different host, user, deploy_to or other settings, you may use ENV[‘STAGE’] variable to identify which target is running now, by example:
if ENV['STAGE']
#. stage options
set :host, "localhost"
set :user, "deploy"
set :deploy_to, "/opt/apps/#{application}"
else
#. production options
set :host, "my.production.host"
set :user, "root"
end