Skip to content

Instantly share code, notes, and snippets.

@jalberto
Created January 28, 2014 16:19
Show Gist options
  • Save jalberto/8670863 to your computer and use it in GitHub Desktop.
Save jalberto/8670863 to your computer and use it in GitHub Desktop.
Basic capistrano 3 deploy
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rvm'
set :application, "myapp"
set :repo_url, "[email protected]:me/myapp.git"
set :user, "deploy"
set :deploy_to, "/home/deploy/myapp"
# set :deploy_via, :copy
set :deploy_via, :remote_cache
set :format, :pretty
set :log_level, :info
set :keep_releases, 5
set :ssh_options, {
# verbose: :debug,
user: fetch(:user),
forward_agent: true
}
set :linked_files, %w{config/database.yml config/.env}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:all), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :restart, :clear_cache do
on roles(:all), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
# desc "Add index to public"
# task :symlink_index do
# on roles(:app) do
# run "ln -nfs #{shared_path}/index.html #{release_path}/public/index.html"
# end
# end
after :finishing, 'deploy:cleanup'
end
server "myserver", roles: %w{app web db}
set :branch, 'master'
set :stage, :production
set :rails_env, "production"
gem 'capistrano', '~> 3.0.0', require: false
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-rvm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment