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.

Using Capifony for Symfony apps deployment.

1,105 views

Published on

Capistrano is an open source tool for running scripts on multiple servers. Capifony - set of instructions called “recipes” for Symfony applications deployment.
Built to make your job a lot easier.

Published in: Technology
  • Be the first to comment

Using Capifony for Symfony apps deployment.

  1. 1. Using Capifony for Symfony apps deployment Žilvinas Kuusas VilniusPHP 0x1B, 2015-02-05 / http://vilniusphp.lt
  2. 2. Who am I? Žilvinas Kuusas lead developer Estina / iSign.io t: @kuusas e: zilvinas@kuusas.lt
  3. 3. How do people deploy? Code ● FTP ● vim ● rsync ● git pull ● ... Database ● Manually manage DB fields ● phpMyAdmin ● mysql < changes.sql ● ...
  4. 4. Symfony - heavy Post-deployment tasks: ● cache:clear ● cache:warmup ● assets:install ● assetic:dump ● doctrine:migrations:migrate ● restart some services ● ...
  5. 5. What if … … you executed a wrong command?
  6. 6. Don’t Repeat Yourself AUTOMATE!
  7. 7. Goals for solid deployment ● One-click deployment ● Deploy in one transaction ● Rollback ● Automated tasks ● Notifications ● 0 downtime ● Confidence
  8. 8. Capistrano Capifony
  9. 9. What Capistrano is? ● Capistrano is an open source tool for running scripts on multiple servers ● Primary use - application deployment ● Capifony - set of instructions called “recipes” for Symfony applications deployment ● Built to make your job a lot easier
  10. 10. Why Capifony? ● Fully supports Symfony features ● Actively maintained since 2009 ● 6 active contributors ● >100 total ● last commit 16 days ago
  11. 11. What do we need? ● Symfony2 application ● Capifony ● SSH access to server (ssh-key recommended)
  12. 12. How it works?
  13. 13. Setup $ sudo gem install capifony $ cd /path/to/your/project $ capifony .
  14. 14. $ capifony .
  15. 15. $ vi app/config/deploy.rb
  16. 16. $ vi app/config/deploy.rb
  17. 17. $ cap deploy
  18. 18. $ cap deploy
  19. 19. Main deployment commands $ cap deploy … $ cap deploy:migrations ... $ cap deploy:rollback
  20. 20. Deployment strategies deployment > scm > production
  21. 21. Deployment strategies scm > deployment > production
  22. 22. Behind scenes
  23. 23. What else Capifony can do? ● Execute Symfony commands on server ● Execute shell commands on server ● Dump remote database and download ● Tail logs ● Turn on/off maintenance page
  24. 24. $ cap -vT # Lists all tasks available $ cap deploy:check $ cap database:copy:to_local $ cap deploy:cold $ cap deploy:pending $ cap deploy:web:disable $ cap deploy:web:enable $ cap symfony:logs:tail $ cap symfony ...
  25. 25. Database migrations Deploy database schema updates in... ● SAFE ● EASY ● STANDARDIZED way…
  26. 26. DoctrineMigrationsBundle
  27. 27. $ app/console doctrine:migrations:diff
  28. 28. Deploying with migrations: $ cap deploy:migrations Rolling-back migrations: $ cap symfony -S task_arguments="doctrine: migrations:migrate 20150205170707 --no-interaction" $ cap deploy:migrations
  29. 29. OPcache ● Create temp file accessible via www ● Make curl request ● Remove file Capistrano recipe for that: https://github.com/occitech/capistrano-recipes/blob/master/Opcache-Recipe.rb
  30. 30. Keeping sessions
  31. 31. Multistage extension Enables deployment to multiple servers $ cap STAGE_NAME deploy Multistage extension: https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
  32. 32. Deploying release package ● CI server builds release package (zip) ● Capifony deploys Capistrano deploy strategy called “archive”: https://github.com/sorccu/capistrano-deploy-strategy-archive
  33. 33. Symfony related configuration
  34. 34. Extending Capistrano It’s Ruby!
  35. 35. Override Capistrano recipes
  36. 36. Listen to events
  37. 37. Debugging
  38. 38. $ cap deploy -d
  39. 39. cap deploy:migrations -s branch=master cap deploy:migrations -S my_var=value Arguments in CLI
  40. 40. Other deployment tools ● Fabric (Python) ● Idephix ● Magellanes ● Deployer ● Laravel / Envoy ● Rocketeer ● Ansible + Tower
  41. 41. Final thoughts Don’t use FTP
  42. 42. Final thoughts AUTOMATE
  43. 43. Questions?
  44. 44. AČIŪ Credits for image authors. “what if…” gif taken from devopsreactions.tumblr.com, deployment strategies - from capifony.org. Couldn’t find the real authors of lizzard and kitty - so if its your’s - THANK YOU.

×