Last active
December 23, 2015 05:59
-
-
Save williamn/6590803 to your computer and use it in GitHub Desktop.
Laravel deployment recipe
This file contains hidden or 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
set :stage, :staging | |
server "example.com", roles: [:app, :web, :db] | |
set :ssh_options, { | |
user: "william", | |
forward_agent: true | |
} | |
set :deploy_to, "/home/william/htdocs/#{fetch(:application)}" | |
set :deploy_via, :remote_cache | |
set :use_sudo, false | |
set :keep_releases, 4 | |
namespace :deploy do | |
task :fix_permissions do | |
on roles(:all) do | |
execute "chmod -R a+w #{current_path}/app/storage" | |
end | |
end | |
task :composer_install do | |
on roles(:all) do | |
execute "cd #{current_path};php ~/bin/composer.phar install --no-dev --no-progress" | |
end | |
end | |
task :migrate_install do | |
on roles(:all) do | |
execute "cd #{current_path};php artisan --env=#{fetch(:stage)} migrate:install" | |
end | |
end | |
task :migrate do | |
on roles(:all) do | |
execute "cd #{current_path};php artisan --env=#{fetch(:stage)} migrate" | |
end | |
end | |
task :symlink_shared do | |
on roles(:all) do | |
execute "mkdir #{current_path}/app/config/#{fetch(:stage)}" | |
execute "ln -s #{shared_path}/app/config/#{fetch(:stage)}/database.php #{current_path}/app/config/#{fetch(:stage)}/database.php" | |
execute "cp #{shared_path}/bootstrap/start.php #{current_path}/bootstrap/start.php" | |
end | |
end | |
task :optimize do | |
on roles(:all) do | |
execute "cd #{current_path};php artisan down" | |
execute "cd #{current_path};php artisan optimize" | |
execute "cd #{current_path};php ~/bin/composer.phar dump-autoload" | |
execute "cd #{current_path};php artisan up" | |
end | |
end | |
end | |
after "deploy:finishing", "deploy:fix_permissions" | |
after "deploy:finishing", "deploy:symlink_shared" | |
after "deploy:finishing", "deploy:migrate" | |
after "deploy:finishing", "deploy:optimize" | |
after "deploy:fix_permissions", "deploy:composer_install" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment