Skip to content

Instantly share code, notes, and snippets.

@jorwan
Last active August 29, 2015 14:14
Show Gist options
  • Save jorwan/1c97b0bf9f6c89d041b2 to your computer and use it in GitHub Desktop.
Save jorwan/1c97b0bf9f6c89d041b2 to your computer and use it in GitHub Desktop.
# config valid only for Capistrano 3.1
lock '3.2.1'
# APPLICATION
set :application, '<application_name>'
set :repo_url, '<repo>'
# GIT
set :deploy_to, '<deploy_to>'
set :deploy_via, :remote_cache
set :scm, :git
# SETTINGS
set :linked_files, %w{<linkd_files>}
set :linked_dirs, %w{<linked_folders>}
set :keep_releases, 5
set :copy_exclude, [".git", ".gitignore", ".tags"]
namespace :deploy do
# create task before for "System under maintenace"
# cap deploy:web:disable # Present a maintenance page to visitors.
# cap deploy:web:enable # Makes the application web-accessible again.
desc 'Setup linked files'
task :touch do
on roles(:web) do
within shared_path do
fetch(:linked_files, []).each do |file|
if !(File.exist?(shared_path.to_s + '/' + file))
info shared_path.to_s + '/' + file + ' = ' + File.exist?(shared_path.to_s + '/' + file).to_s
execute :touch, shared_path.to_s + '/' + file
end
end
end
end
end
desc 'Install composer dependencies'
task :composer_install do
on roles(:web) do
within release_path do
execute 'composer', 'install', '--no-dev', '--optimize-autoloader'
end
end
end
desc 'Setup Laravel folder permissions'
task :permissions do
on roles(:web), in: :sequence, wait: 5 do
within release_path do
execute :chmod, "-R 777 app/storage/cache"
execute :chmod, "-R 777 app/storage/logs"
execute :chmod, "-R 777 app/storage/meta"
execute :chmod, "-R 777 app/storage/sessions"
execute :chmod, "-R 777 app/storage/views"
end
end
end
before 'deploy:check:linked_files', 'deploy:touch'
after :updated, 'deploy:composer_install'
after :published, 'deploy:permissions'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment