public
Created

Symfony Capistrano deployment

  • Download Gist
Capfile
Ruby
1 2 3 4 5 6
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
 
load 'config/deploy' # remove this line to skip loading any of the default tasks
 
before 'deploy:create_symlink', 'deploy:build'
before 'deploy:create_symlink', 'deploy:migrate'
deploy.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
set :stages, %w(production staging)
set :default_stage, 'staging'
 
require 'capistrano/ext/multistage'
 
devs = {} and remotes = `git remote -v`.each_line {|s| devs[s.split(' ')[0]] = s.split(' ')[1] }
 
dev = ENV['DEV'] || 'origin'
unless repo = devs[dev]
repo = devs['origin']
end
 
# Repo options
set :application, 'Sample Symfony Application'
set :repository, repo
set :scm, :git
 
# Github stuff
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
 
# Deployment options
set :branch, ENV['BRANCH'] || 'master'
set :deploy_env, 'production'
set :use_sudo, false
set :user, 'deploy'
 
namespace :deploy do
task :build, :roles => :web do
run "phing -f #{latest_release}/build.xml -Dbuild_settings_file=#{shared_path}/system/build.settings -Dvendor_path=#{shared_path}/system/vendor"
end
task :migrate, :roles => :db do
run "phing -f #{latest_release}/build.xml migrate-db"
end
end
production.rb
Ruby
1 2 3 4
role :web, 'your-website.com'
role :db, 'db.your-website.com', :primary => true
 
set :deploy_to, '/var/www/vhosts/your-website.com'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.