Last active
August 29, 2015 14:10
-
-
Save bosskovic/5575efea9323db8d0f92 to your computer and use it in GitHub Desktop.
capistrano setup
This file contains 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
require 'capistrano/setup' | |
require 'capistrano/deploy' | |
require 'capistrano/rvm' | |
require 'capistrano/bundler' | |
require 'capistrano/rails/migrations' | |
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } | |
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r } |
This file contains 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
lock '3.2.1' | |
set :application, 'fungiorbis_rails' | |
set :deploy_user, 'root' | |
set :scm, :git | |
set :repo_url, "[email protected]:bosskovic/#{fetch(:application)}.git" | |
set :rvm_type, :auto | |
set :rvm_ruby_version, '2.1.5' | |
set :format, :pretty | |
set :log_level, :debug | |
set :pty, true | |
set :linked_files, %w{config/database.yml config/secrets.yml} | |
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | |
set :keep_releases, 3 | |
set :tests, [] | |
set(:config_files, %w( | |
database.yml | |
secrets.yml | |
nginx.conf | |
log_rotation | |
)) | |
set(:executable_config_files, []) | |
set(:symlinks, [ | |
{ | |
source: 'nginx.conf', | |
link: "/etc/nginx/sites-enabled/#{fetch(:full_app_name)}" | |
}, | |
{ | |
source: 'log_rotation', | |
link: "/etc/logrotate.d/#{fetch(:full_app_name)}" | |
}, | |
{ | |
source: 'monit', | |
link: "/etc/monit/conf.d/#{fetch(:full_app_name)}.conf" | |
} | |
]) | |
namespace :deploy do | |
# make sure we're deploying what we think we're deploying | |
before :deploy, 'deploy:check_revision' | |
# only allow a deploy with passing tests to deployed | |
before :deploy, 'deploy:run_tests' | |
# compile assets locally then rsync | |
after :finishing, 'deploy:cleanup' | |
# remove the default nginx configuration as it will tend to conflict with our configs. | |
before 'deploy:setup_config', 'nginx:remove_default_vhost' | |
# reload nginx to it will pick up any modified vhosts from setup_config | |
after 'deploy:setup_config', 'nginx:reload' | |
# Restart monit so it will pick up any monit configurations we've added | |
after 'deploy:setup_config', 'monit:restart' | |
desc 'Restart application' | |
task :restart do | |
on roles(:app), in: :sequence, wait: 5 do | |
execute :mkdir, '-p', "#{ release_path }/tmp" | |
execute :touch, release_path.join('tmp/restart.txt') | |
end | |
end | |
after :publishing, :restart | |
end |
This file contains 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, :production | |
set :branch, 'master' | |
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}" | |
set :server_name, '178.79.152.32' | |
server '178.79.152.32', user: 'root', roles: %w{web app db}, primary: true | |
set :deploy_to, "/var/www/#{fetch(:full_app_name)}" | |
set :rails_env, :production | |
set :enable_ssl, true | |
# set :ssh_options, { | |
# keys: %w(/home/m/.ssh/github/id_rsa), | |
# forward_agent: true, | |
# auth_methods: %w(password) | |
# } |
This file contains 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
cap production deploy:setup_config | |
# ssh to the serve and update database.yml and secrets.yml in shared/config | |
$ bundle exec cap production deploy | |
$ bundle exec cap production deploy --dry-run | |
$ bundle exec cap production deploy --prereqs | |
$ bundle exec cap production deploy --trace |
This file contains 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
gem 'capistrano' | |
gem 'capistrano-rails' | |
gem 'capistrano-bundler' | |
gem 'capistrano-rvm', require: false | |
# in shell: | |
# bundle install | |
# bundle exec cap install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment