painless deployment with capistrano
TRANSCRIPT
ВЫКЛАДКАБЕЗ БОЛИ С
CAPISTRANOPAINLESS DEPLOYMENT WITH CAPISTRANO
/ Николай Кугаевский @kugaevsky
MONSTAZ!PuppetChefSaltAnsible
CAPISTRANOCapistrano is a remote server automation and deployment tool
written in Ruby.
It supports the scripting and execution of arbitrary tasks, andincludes a set of sane-default deployment workflows.
CONFIG
# config/deploy.rbset :application, 'slides'set :repo_url, '[email protected]:kugaevsky/slides.git'
# config/deploy/staging.rbrole :app, %w{[email protected]}set :deploy_to, '/home/kugaevsky/www/slides.kugaevsky.ru'set :user, 'nick'
ANATOMY LOCAL
my_perfect_app├── Capfile├── config│ ├── deploy│ │ ├── production.rb│ │ ├── staging.rb│ │ └── ...│ └── deploy.rb└── lib └── capistrano └── tasks
ANATOMY HOST
my_perfect_app├── current → ../releases/20141209222103├── releases│ ├── 20141209220703│ ├── 20141209222103│ └── ...├── repo│ ├── branches│ ├── config│ ├── description│ └── ...└── shared ├── node_modules ├── uploads ├── vendor └── ...
DEPLOY FLOW
deploy:starting # start a deployment, make sure everything is readydeploy:started # started hook (for custom tasks)deploy:updating # update server(s) with a new releasedeploy:updated # updated hookdeploy:publishing # publish the new releasedeploy:published # published hookdeploy:finishing # finish the deployment, clean up everythingdeploy:finished # finished hook
ROLLBACK FLOW
deploy:startingdeploy:starteddeploy:reverting # revert server(s) to previous releasedeploy:reverted # reverted hookdeploy:publishingdeploy:publisheddeploy:finishing_rollback # finish the rollback, clean up everythingdeploy:finished
PLUGINS!
# Capfilerequire 'capistrano/rvm'require 'capistrano/rbenv'require 'capistrano/chruby'require 'capistrano/bundler'require 'capistrano/rails/assets'require 'capistrano/rails/migrations'
REAL WORLD EXAMPLE
# config/deploy.rbdesc 'Create symlinks for npm modules'task :npm do on roles(:app) do execute "ln -nfs #{shared_path}/node_modules #{release_path}/node_modules" endend
desc 'Install npm modules'task :npm do on roles(:app) do execute "cd #{release_path} && npm install" endend
desc 'Compile assets'task :compile_assets do on roles(:app) do execute "cd #{release_path} && #{shared_path}/node_modules/.bin/gulp compile:production" endend
ALTERNATIVESVlad the DeployerMina
READINGCapistrano official siteRepository on GitHubHow To Use Capistrano to Automate Deployments
СПАСИБОВЫКЛАДКА БЕЗ БОЛИ С CAPISTRANO
PAINLESS DEPLOYMENT WITH CAPISTRANO
для
http://slides.kugaevsky.ru/Николай Кугаевский rannts#3