Skip to content

Instantly share code, notes, and snippets.

@allanfreitas
Forked from chipotle/deploy.rb
Created May 19, 2013 11:53
Show Gist options
  • Select an option

  • Save allanfreitas/5607447 to your computer and use it in GitHub Desktop.

Select an option

Save allanfreitas/5607447 to your computer and use it in GitHub Desktop.
# This makes a few assumptions:
#
# - You are using a similar .gitignore to Laravel's default, so your
# vendor directory and composer(.phar) are not under version control
# - Composer is installed as an executable at /usr/local/bin/composer
#
# If you don't have Composer installed globally, you can modify the
# appropriate task (:composer_install). Or make your life simpler and
# install Composer globally.
# Fill in application-specific configuration options below
set :application, "{Application name}"
set :repository, "{git repository}"
set :scm, :git
set :scm_username, "{username}"
role :web, "example.net"
role :app, "example.net"
role :db, "example.net", :primary => true
set :deploy_to, "/path/to/deployment"
set :deploy_via, :remote_cache
set :use_sudo, false # I don't need sudo, but you might
set :ssh_options, {:forward_agent => true}
set :copy_exclude, [".git", ".gitignore", ".tags", ".tags_sorted_by_file"]
set :keep_releases, 5
# Laravel deployment
namespace :deploy do
task :update do
transaction do
update_code
copy_config
composer_install
link_shared
laravel_migrate
symlink
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 :link_shared do
transaction do
run "ln -nfs #{shared_path}/system #{current_release}/public/system"
end
end
task :laravel_migrate do
transaction do
run "php #{current_release}/artisan migrate"
end
end
task :laravel_rollback do
run "php #{deploy_to}/#{current_dir}/artisan migrate:rollback"
end
task :restart do
transaction do
# set writable storage dir
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/cache ]; then chmod -R 777 $mydir/cache; rm -f $mydir/cache/*; fi"
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/database ]; then chmod -R 777 $mydir/database; fi"
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/logs ]; then chmod -R 777 $mydir/logs; fi"
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/sessions ]; then chmod -R 777 $mydir/sessions; fi"
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/views ]; then chmod -R 777 $mydir/views; rm -f $mydir/views/*; fi"
run "mydir=\"#{deploy_to}/#{current_dir}/app/storage\";if [ -d $mydir/work ]; then chmod -R 777 $mydir/work; fi"
end
end
task :composer_install do
transaction do
run "cd #{current_release};/usr/local/bin/composer install"
end
end
# This task lets you keep server-specific configuration files in "shared/config/".
# Any file there will just be copied to your app/config directory.
task :copy_config do
transaction do
run "cp #{shared_path}/config/* #{current_release}/app/config/"
end
end
end
after "deploy:rollback", "deploy:laravel_rollback"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment