• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 

ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)

on

  • 2,404 views

http://www.zfconf.ru/2012/talks/capistrano-for-deployment-php-applications/

http://www.zfconf.ru/2012/talks/capistrano-for-deployment-php-applications/

Statistics

Views

Total Views
2,404
Views on SlideShare
1,229
Embed Views
1,175

Actions

Likes
2
Downloads
16
Comments
0

1 Embed 1,175

http://www.zfconf.ru 1175

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин) ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин) Presentation Transcript

    • Capistrano длядеплоймента PHP приложений Рома Лапин, Evercode Lab@memphys, roma@evercodelab.com
    • If you cannot do your deployments with one command then you are DOING IT WRONG. Chris Hartjes, “Infrastructure Debt”(http://www.littlehart.net/atthekeyboard/2011/11/03/infrastructure-debt/)
    • Обновить файлыОбновить базуСоздать файлы, папки, симлинкиВыставить праваСбросить кэшСохранить контентОткатиться в случае ошибки
    • FTP-клиентыVCS, hooksPhingShell scriptRsyncWePloy
    • SSHGit/SVN/Mercurial/...Server
    • © http://capifony.org/
    • ├── current -> /var/www/zf-capistrano/releases/20120414205035├── releases│   ├── 20120414204853│   │   ├── application│   │   ├── ...│   └── 20120414205035│   ├── application│   ├── ...└── shared ├── cached-copy │   ├── application │   ├── ... └── public └── uploads
    • $ gem install capistrano
    • $ cd ~/Sites/mycoolproject$ capify .[add] writing ./Capfile[add] making directory ./config[add] writing ./config/deploy.rb[done] capified!
    • config/deploy.rbset :application, "application_name"set :deploy_to, "/var/www/#{application}"
    • config/deploy.rbset :scm, :gitset :repository, "git@github.com:user/app.git"set :deploy_via, :remote_cacheset :branch, "master"set :keep_releases, 3
    • config/deploy.rbserver "domain", :app, :web, :db, :primary => trueset :ssh_options, {:forward_agent => true, :port => 22}set :user, "deployer"set :use_sudo, false
    • $ cap -h$ cap -T
    • config/deploy.rbnamespace :deploy do    task :start do    end    task :stop do    end    task :migrate do    end    task :restart do    endend
    • $ gem install railsless-deployCapfilerequire railsless-deployload config/deploy
    • $ cap deploy:setup$ cap deploy:check
    • $ cap deploy
    • $ cap deploy:update$ cap deploy:cleanup
    • $ cap deploy:rollback
    • Capfile (ZF1)load config/deploy
    • Capfile (ZF1)load config/deploy
    • Capfile (ZF1)load config/deployload application/configs/deploy
    • application/configs/deploy.rbnamespace :myproject do    task :symlink, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink"
    • application/configs/deploy.rbnamespace :myproject do    task :symlink, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink"run "mkdir -p #{shared_path}/library"run "chmod -R 755 #{shared_path}/library"run "ln -nfs /path/to/zf/library/Zend #{shared_path}/library/Zend"run "ln -nfs #{shared_path}/library #{release_path}/library"
    • config/deploy.rb (ZF2)namespace :myproject do    task :symlink, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink"
    • config/deploy.rb (ZF2)namespace :myproject do    task :symlink, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink"run "mkdir -p #{shared_path}/vendor/ZendFramework/library"run "chmod -R 755 #{shared_path}/vendor/ZendFramework/library"run "ln -nfs /path/to/ZendFramework-2.0.0beta3/library/Zend #{shared_path}/vendor/ZendFramework/library/Zend"run "rm -rf #{release_path}/vendor"run "ln -nfs #{shared_path}/vendor #{release_path}/vendor"
    • application/configs/deploy.rbnamespace :myproject do    task :uploads, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink", "myproject:uploads"
    • application/configs/deploy.rbnamespace :myproject do    task :uploads, :roles => :app do ...    endendafter "deploy:symlink", "myproject:symlink", "myproject:uploads"run "mkdir -p #{shared_path}/public/uploads"run "chmod -R 775 #{shared_path}/public/uploads"run "ln -nfs #{shared_path}/public/uploads #{release_path}/public/uploads"
    • application/configs/deploy.rbtask :disable do ...endafter "deploy:update_code", "myproject:disable"
    • application/configs/deploy.rbtask :disable do ...endafter "deploy:update_code", "myproject:disable"run "echo Site is on maintenance right now. Sorry. > #{shared_path}/public/maintenance.html"run "cp #{shared_path}/public/maintenance.html #{latest_release}/public/maintenance.html"
    • application/configs/deploy.rbtask :enable do ...endafter "deploy:symlink", "myproject:enable"
    • application/configs/deploy.rbtask :enable do ...endafter "deploy:symlink", "myproject:enable"run "rm -f #{latest_release}/public/maintenance.html"
    • application/configs/deploy.rbtask :migrate do ...endafter "deploy:finalize_update", "myproject:migrate"
    • application/configs/deploy.rbtask :migrate do ...endafter "deploy:finalize_update", "myproject:migrate"on_rollback { run "#{release_path}/bin/doctrine migrations:migrate down" }run "#{release_path}/bin/doctrine migrations:migrate"
    • application/configs/deploy.rbtask :unicornsandwizards do # notify by email # post to irc or group chat # send SMS # activate SkyNet # order some Pizzaendafter "deploy:finalize_update", "myproject:unicornsandwizards"
    • zf-capistrano https://github.com/memphys/zf-capistranozf2-capistrano https://github.com/memphys/zf2-capistranoCapistrano home https://github.com/capistrano/capistrano/wiki
    • MultistageCapifony (http://capifony.org)Webistrano
    • Спасибо за вниманиеРома ЛапинEvercode Labroma@evercodelab.com@memphys