Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Deployment talk dpc 13

1,295 views

Published on

About determining your deployment strategy and creating a deployment script (with capistrano and capifony).

Published in: Technology
  • Hey Robbert!
    Do you have vide/audio for that?
    Thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Deployment talk dpc 13

  1. 1. Deploying your apps.. the right way!Robbert van den BogerdJune 8th, 2013
  2. 2. Introduction
  3. 3. whoamiDeveloper at IbuildingsWeb enthusiastTravellerThe Average Joe
  4. 4. Disclaimer
  5. 5. DEPLOYMENTSo what are we here for?
  6. 6. TOCHorror storiesCommon pitfallsWhat we wantDeployment from beginning to endIntegration tools
  7. 7. Horror stories
  8. 8. Horror storiesFTP: Forever Taking Process
  9. 9. Horror storiesRsync: for oldschool sysadmins
  10. 10. Horror storiesVersioning checkout
  11. 11. Horror storiesTeamviewer: REALLY?
  12. 12. Problems & solutions
  13. 13. Common pitfallsManual operationsSloow deployment processDowntimeCacheMigrationsNo turning back
  14. 14. Manual operationsNo!The Bus FactorAnyplace, anywhere, anytimeConfidence
  15. 15. No turning back
  16. 16. Zero downtimeNo more UC pages!Quick deploysSmaller releasesAutomate
  17. 17. Cache
  18. 18. Migrations
  19. 19. Common pitfallsManual operationsSloow deployment processDowntimeCacheMigrationsNo turning back
  20. 20. What we wantManual operations AutomationSloow deployments Quick rolloutsZero DowntimeCache warmed upMigrationsNo turning back Rollbacks
  21. 21. From the beginning..
  22. 22. “Victorious warriors first winand then go to war”- Sun Tzu
  23. 23. Think before you (sign a contr)act!
  24. 24. Managing expectationsCustomerUsersProject managerDevs/testers
  25. 25. Deployment strategyRelease cycleServer setupBranching strategyTools to use
  26. 26. DTAP
  27. 27. So, lets cut to the point..
  28. 28. Use git
  29. 29. Seriously, use git!ReliableSuper fastEasy branching/mergingDistributedGithub:Awesome uiExtrasPRsIntegration with existing deployment tools
  30. 30. Dependency managementFrameworkLibrariesBuild/QA toolsCompany private repos
  31. 31. Drumroll please..
  32. 32. Composer
  33. 33. MigrationsWrite your own scriptUse one of the great existing ones:- Doctrine migrations- DbPatch- Shipped with your framework/orm?
  34. 34. BackupsAlways create one!..unless its not possible =]
  35. 35. Directory structure/var/www/rule34//var/www/rule34/releases/var/www/rule34/releases/20130606143000/var/www/rule34/releases/20130606143400Live www dir:/var/www/rule34/current > releases/20130606143400
  36. 36. Deployment script> Do a backup> Create new directory> Update your code> Update dependencies> Run migrations> Warmup cache> ...
  37. 37. Lets start scripting!
  38. 38. Wait a second..
  39. 39. Existing toolsFabricPhing/AntChefCapistrano
  40. 40. CapistranoPowerfulEasy setupEvent/task based, easy to hook intoWritten in rubyMultiple serversMultistage extension
  41. 41. CapifonyThe power of CapistranoPre-configured for SymfonyDeploy with 1 single config file
  42. 42. Setup
  43. 43. Local setupgem install capifonycd /var/www/rule34/capifony install .
  44. 44. Capifony config# app/config/deploy.rbset :application, "My App"set :deploy_to, "/var/www/my-app.com"set :domain, "my-app.com"set :scm, :gitset :repository, "ssh-gitrepo-domain.com:/path/to/repo.git"
  45. 45. Remote setupcd /var/www/rule34/cap deploy:setup
  46. 46. Deploy
  47. 47. Capifony deploycd /var/www/rule34/cap deploy# made a boo-boo?cap deploy:rollback
  48. 48. Configurationset :model_manager, "doctrine"
  49. 49. Configurationset :update_vendors, falseset :use_composer, trueset :vendors_mode, "install"
  50. 50. Configurationset :dump_assetic_assets, true
  51. 51. Configurationset :shared_children, [app_path+"/logs", "data"]set :writable_dirs, [app_path+"/logs", app_path+"/cache", "data"]
  52. 52. Directory structure/var/www/rule34/releases/shared/shared/data/shared/app/logsSymlink:/var/www/rule34/releases/20130606143400/data > ../../shared/data
  53. 53. DTAP
  54. 54. Multistaging# app/config/deploy.rbrequire capistrano/ext/multistageset :stages, %w(prod acc test dev)set :default_stage, "test"set :stage_dir, "app/config/deploy/stages"# app/config/deploy/stages/test.rbserver rule34.mytestserver.comset :symfony_env_prod, "test"
  55. 55. User permissionsset :use_sudo, falseset :user, "deployment"set :group, "www-data"set :webserver_user, "www-data":use_set_permissions, true:permission_method, “chmod” # or “acl” or “chown”
  56. 56. Maintenance pagecap deploy:web:disable REASON="hardware upgrade" UNTIL="12pm Central Time"# override templateset :maintenance_template_path, “app/Resources/uc.html”
  57. 57. Tips n Tricks# determine tag/branch/commit/sha1 on the flyset :branch dodefault_tag = `git describe --abbrev=0 --tags`.split("n").lasttag = Capistrano::CLI.ui.ask "Tag/branch to deploy (make sure topush the tag first): [#{default_tag}] "tag = default_tag if tag.empty?tagend
  58. 58. Tips n Tricks# enable ssh client interactiondefault_run_options[:pty] = true
  59. 59. Tips n Tricks# enable agent forwardingssh_options[:forward_agent] = true
  60. 60. Tips n Tricks# cleanup old release dirs automaticallyset :keep_releases, 3after "deploy", "deploy:cleanup"
  61. 61. Tips n Tricks# run doctrine migrations after code updateafter “update_code”, “doctrine:migrations:migrate”
  62. 62. Tips n Tricks# run any symfony console commandbefore “any_task”, “symfony:cache:clear”
  63. 63. Whats next?
  64. 64. System provisioningUpgrade PHP 5.3 > 5.4Upgrade MySqlInstall RedisInstall Node.jsEtc..
  65. 65. ChefVersion control your infrastructureIdentical environmentsIntegration with Vagrant
  66. 66. Chef# run chef after code updateafter “update_code”, “provision”task :provision doend
  67. 67. Chef# run chef after code updateafter “update_code”, “provision”task :provision dorun "#{sudo} chef-solo -c#{release_path}/chef/config.rb#{release_path}/chef/chef_#{stage}.json"end
  68. 68. Vagrant
  69. 69. Build automation
  70. 70. Jenkins
  71. 71. The end result
  72. 72. The usual stuffTwitter: @nickednameJoind.in: https://joind.in/8461
  73. 73. Further reading“A basic git capistrano workflow”http://labs.headshift.com/2012/02/29/a-basic-gitcapistrano-workflow/“A successful git branching model”http://nvie.com/posts/a-successful-git-branching-model/The dbPatch projecthttp://www.dbpatch-project.com/“Continuous deployment with symfony2, jenkins and capifony”http://jeremycook.ca/2012/11/04/continuous-deployment-with-symfony2-jenkin“Software branching and parallel universes”http://www.codinghorror.com/blog/2007/10/software-branching-and-parallel-un

×