Skip to content

Instantly share code, notes, and snippets.

@pnegri
Created May 10, 2012 19:14
Show Gist options
  • Save pnegri/2655224 to your computer and use it in GitHub Desktop.
Save pnegri/2655224 to your computer and use it in GitHub Desktop.
Capistrano Deploy Recipe for Pure PHP Projects
require 'rubygems'
require 'railsless-deploy'
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
set :application, "PROJECT NAME"
set :repository, "GITHUB REPO URL"
default_run_options[:pty] = true
set :normalize_asset_timestamps, false
role :web, "10.0.0.6" # Your HTTP server, Apache/etc
role :app, "10.0.0.6" # This may be the same as your `Web` server
role :db, "10.0.0.6", :primary => true # This is where Rails migrations will run
role :db, "10.0.0.6"
tags = `git tag`.split("\n").reverse
ind = 0
puts ""
puts "Repository Tags:"
puts "#"*30
tags.each do |t|
puts "#{ind}) #{t}"
ind = ind+1
end
puts "#"*30
set :branch do
default_tag = `git tag`.split("\n").last
tag = Capistrano::CLI.ui.ask "Tag to deploy (make sure to push the tag first): [#{default_tag}] "
tag = default_tag if tag.empty?
tag
end
set :user, 'app'
set :admin_runner, 'root'
set :scm, :git
set :deploy_via, :remote_cache
set :deploy_to, "/home/app/#{application}"
set :use_sudo, true
set :shared_children, %w()
namespace :deploy do
desc "Finalize Update"
task :finalize_update do
run "ln -nsf #{shared_path}/config/database.php #{current_release}/app/config"
run "ln -nsf #{shared_path}/storage #{current_release}/public_html/storage"
end
namespace :web do
task :disable do
run "touch #{current_release}/public_html/maintenance.html"
end
task :enable do
run "rm -rf #{current_release}/public_html/maintenance.html"
end
end
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} /etc/init.d/nginx restart"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment