Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Capistrano 3
Deployment
Creston Jamison
RubyTree Software, Inc.
What is Capistrano?
 A remote server automation and deployment
tool.
 Version 2 is mostly Rails specific and used a
cust...
Breaking It Up
 capistrano
 capistrano-rails
 capistrano-bundler
 capistrano-rbenv / rvm / chruby
Nice
 In general, less configuration to deploy rails.
 Multi-Stage by default
 Easily sym link files and folders (e.g.,...
Where does my config go???
 Version 2
 Gemfile -> only capistrano
 Capfile -> no changes
 config/deploy.rb -> all conf...
Gemfile
group :development do
gem 'capistrano-rails', '~> 1.1'
end
Run
bundle
bundle exec cap install
 Setup public key authentication to log in as
deploy_user.
Cap file
require 'capistrano/deploy'
require 'capistrano/rails'
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# ...
config/deploy.rb
set :application, 'test_deploy'
set :repo_url,
'git@github.com:username/test_deploy.git'
set :deploy_to,
...
config/deploy.rb, part 2
set :user, 'deploy_username'
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin ...
config/deploy.rb, part 3
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, w...
config/deploy/production.rb
role :app, %w{deploy_user@ip_address:port}
role :web, %w{deploy_user@ip_address:port}
role :db...
Task Example
desc 'Create a new sitemap'
task :create_sitemap do
on roles(:app) do
within release_path do
with rails_env: ...
Deploying
 Ensure your web (apache, nginx) and app (unicorn,
puma, passenger) are configured.
 bundle exec cap productio...
Gotchas
 Shared directory structure on the server has
changed from version 2.
 Shared
[linked files / folders]
Assets
Bu...
References
http://capistranorb.com/
https://github.com/capistrano
https://github.com/capistrano/capistrano
https://github....
Questions?
Creston Jamison
@crestonjamison
creston.jamison@rubytreesoftware.com
Prochain SlideShare
Chargement dans…5
×

Capistrano 3 Deployment

860 vues

Publié le

Capistrano 3 has been rebuilt from the ground up. Learn how to transition from using Capistrano version 2 to Capistrano version 3.

Publié dans : Logiciels
  • Soyez le premier à commenter

Capistrano 3 Deployment

  1. 1. Capistrano 3 Deployment Creston Jamison RubyTree Software, Inc.
  2. 2. What is Capistrano?  A remote server automation and deployment tool.  Version 2 is mostly Rails specific and used a custom DSL.  Version 3 is re-written from the ground up and is trying to be more agnostic.  Version 3 uses Rake with methods included to easily run tasks “on” servers.
  3. 3. Breaking It Up  capistrano  capistrano-rails  capistrano-bundler  capistrano-rbenv / rvm / chruby
  4. 4. Nice  In general, less configuration to deploy rails.  Multi-Stage by default  Easily sym link files and folders (e.g., config/database.yml, log)  Rails: database migrations automatically run during deploy  Deployments have more granularity for defining when tasks occur  Easily setup parallelism for tasks.
  5. 5. Where does my config go???  Version 2  Gemfile -> only capistrano  Capfile -> no changes  config/deploy.rb -> all configuration  Version 3  Gemfile -> capistrano + others  Capfile -> require dependencies  config/deploy.rb -> shared configuration (set)  config/deploy/[env].rb -> server role configuration  lib/capistrano/tasks -> Rake files for tasks
  6. 6. Gemfile group :development do gem 'capistrano-rails', '~> 1.1' end
  7. 7. Run bundle bundle exec cap install  Setup public key authentication to log in as deploy_user.
  8. 8. Cap file require 'capistrano/deploy' require 'capistrano/rails' # require 'capistrano/rvm' # require 'capistrano/rbenv' # require 'capistrano/chruby' # require 'capistrano/bundler' # require 'capistrano/rails/assets' # require 'capistrano/rails/migrations'
  9. 9. config/deploy.rb set :application, 'test_deploy' set :repo_url, 'git@github.com:username/test_deploy.git' set :deploy_to, '/my/server/directory/test_deploy'
  10. 10. config/deploy.rb, part 2 set :user, 'deploy_username' set :linked_files, %w{config/database.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle}
  11. 11. config/deploy.rb, part 3 namespace :deploy do desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do # execute :touch, release_path.join('tmp/restart.txt') end end after :publishing, :restart end
  12. 12. config/deploy/production.rb role :app, %w{deploy_user@ip_address:port} role :web, %w{deploy_user@ip_address:port} role :db, %w{deploy_user@ip_address:port} OR server ‘ip_address', user: ‘deploy_user', roles: %w{web app db}, ssh_options: { port: port }
  13. 13. Task Example desc 'Create a new sitemap' task :create_sitemap do on roles(:app) do within release_path do with rails_env: fetch(:stage) do execute :rake, ‘sitemap:create’ end end end end after :finished, :create_sitemap
  14. 14. Deploying  Ensure your web (apache, nginx) and app (unicorn, puma, passenger) are configured.  bundle exec cap production git:check  bundle exec cap production deploy:check  Create ~/shared/config/database.yml  bundle exec cap production deploy
  15. 15. Gotchas  Shared directory structure on the server has changed from version 2.  Shared [linked files / folders] Assets Bundle  Migrations happen automatically  Deployment flow terminology has changed
  16. 16. References http://capistranorb.com/ https://github.com/capistrano https://github.com/capistrano/capistrano https://github.com/capistrano/rails
  17. 17. Questions? Creston Jamison @crestonjamison creston.jamison@rubytreesoftware.com

×