Created
November 13, 2012 05:28
-
-
Save ichi/4064116 to your computer and use it in GitHub Desktop.
capistrano + cakephp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
## config/deploy.rb | |
# pp | |
require 'pp' | |
# capistrano-ext | |
require "capistrano/ext/multistage" | |
#################################################### | |
# Application | |
#################################################### | |
set :application, "hogehoge" # アプリ名 | |
set :keep_releases, 5 # releasesに残すverの数 | |
#################################################### | |
# Deploy user | |
#################################################### | |
set :use_sudo, false | |
default_run_options[:pty] = true | |
##################################################### | |
# Git | |
##################################################### | |
set :scm, :git | |
set :scm_verbose, true | |
set :repository, "git+ssh://hoge.net/home/git/repos/hoge.git" # 対象レポジトリ | |
#set :deploy_via, :copy | |
#set :git_enable_submodules, 1 | |
###################################################### | |
# Cakephp | |
###################################################### | |
set :application_root, "app" | |
set :application_web_root, "#{application_root}/webroot" | |
set :application_tmp_dir, "#{application_root}/tmp" | |
set :shared_children, %w(logs cache sessions test) # override default | |
###################################################### | |
# Tasks | |
###################################################### | |
namespace :deploy do | |
# Railsアプリケーション関連のタスクを消します。 | |
%w(restart start stop cold migrate migrations).each {|t| task(t){} } | |
desc 'deploy先ディレクトリをふっ飛ばしてからsetup' | |
task :force_setup do | |
sudo "rm -fr #{deploy_to}" | |
deploy.setup | |
end | |
after 'deploy:setup' do | |
# chmod o+w しとく | |
dirs = shared_children.map{|d| File.join(shared_path, d) } | |
dirs_str = dirs.join ' ' | |
sudo "chmod o+w #{dirs_str}" | |
end | |
task :finalize_update do | |
sudo "chmod -R g+w #{release_path}" | |
# tmp内dirをrmしてsharedにlink | |
shared_children.each do |d| | |
target = "#{release_path}/#{application_tmp_dir}/#{d}" | |
run <<-CMD | |
rm -fr #{target} && | |
ln -s #{shared_path}/#{d} #{target} | |
CMD | |
end | |
end | |
# restart後にcleanup | |
after "deploy:start", "deploy:cleanup" | |
after "deploy:restart", "deploy:cleanup" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
## config/deploy/development.rb | |
#################################################### | |
# Application | |
#################################################### | |
set :deploy_environment, 'development' | |
set :deploy_to, '/path/to/hoge' # deploy先のディレクトリ | |
##################################################### | |
# Servers | |
###################################################### | |
role :app, 'hoge.net', 'fuga.com' # deploy先サーバー | |
##################################################### | |
# Git | |
##################################################### | |
set :branch, 'develop' | |
###################################################### | |
# Ovarride existing tasks | |
###################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment