you must have capistrano installed
This Cafile could be placed on your application root directory, this is tested with laravel 4.0.x
.
load "deploy" | |
set :application, "App Name" # Your app name | |
set :repository, "[email protected]:xxxxx/xxx.git" # Your git repository | |
set :user, "user_ssh" | |
set :document_root, "/home/#{user}/www/awesome_app" | |
set :deploy_via, :remote_cache | |
# SSH Settings | |
set :password, "password_ssh" | |
set :use_sudo, false | |
set :ssh_options, {:forward_agent => true} | |
set :copy_exclude, [".git",".gitignore"] # or any match like [".svn","/documents-on-repo-but-dont-deploy"] | |
set :keep_releases, 10 # only keep 10 version to save space | |
default_run_options[:pty] = true | |
role :app, "<server.example.com>" | |
role :web, "<server.example.com>" | |
# We need to over write a lot of the core functionality here | |
# since we don't need migrations, lots of the symlink stuff | |
# and server restarting. | |
# cap develop deploy:setup | |
# cap develop deploy:check | |
# cap develop deploy | |
task :develop do | |
set :branch, "develop" | |
set :artisan_env, "develop" | |
set :deploy_to, "#{document_root}/develop" | |
end | |
# cap staging deploy:setup | |
# cap staging deploy:check | |
# cap staging deploy | |
task :staging do | |
set :branch, "staging" | |
set :artisan_env, "stage" | |
set :deploy_to, "#{document_root}/staging" | |
end | |
# cap production deploy:setup | |
# cap production deploy:check | |
# cap production deploy | |
task :production do | |
set :branch, "master" | |
set :artisan_env, "production" | |
set :deploy_to, "#{document_root}/production" | |
end | |
# This is strictly for PHP deploys | |
namespace :deploy do | |
task :update do | |
transaction do | |
update_code | |
symlink | |
composer_install | |
laravel_migrate | |
end | |
end | |
task :finalize_update do | |
transaction do | |
run "chmod -R g+w #{releases_path}/#{release_name}" | |
end | |
end | |
task :symlink do | |
transaction do | |
run "ln -nfs #{current_release} #{deploy_to}/#{current_dir}" | |
end | |
end | |
task :composer_install do | |
desc "Install composer packages" | |
transaction do | |
run "php /usr/bin/composer install --working-dir #{deploy_to}/#{current_dir}" | |
end | |
end | |
task :laravel_migrate do | |
transaction do | |
run "php #{deploy_to}/#{current_dir}/artisan --env=#{artisan_env} migrate" | |
end | |
end | |
task :laravel_rollback do | |
run "php #{deploy_to}/#{current_dir}/artisan --env=#{artisan_env} migrate:rollback" | |
end | |
task :restart do | |
transaction do | |
# set writable storage dir | |
run "chmod -R 777 #{deploy_to}/#{current_dir}/app/storage/cache" | |
run "chmod -R 777 #{deploy_to}/#{current_dir}/app/storage/logs" | |
run "chmod -R 777 #{deploy_to}/#{current_dir}/app/storage/meta" | |
run "chmod -R 777 #{deploy_to}/#{current_dir}/app/storage/sessions" | |
run "chmod -R 777 #{deploy_to}/#{current_dir}/app/storage/views" | |
# remove some junk file | |
run "rm -f #{deploy_to}/#{current_dir}/app/storage/cache/*" | |
run "rm -f #{deploy_to}/#{current_dir}/app/storage/views/*" | |
end | |
end | |
end | |
after "deploy:rollback", "deploy:laravel_rollback" |