Post on 03-Aug-2015
Using Capifony for Symfony apps deployment
Žilvinas Kuusas
VilniusPHP 0x1B, 2015-02-05 / http://vilniusphp.lt
How do people deploy?
Code ● FTP● vim● rsync● git pull● ...
Database● Manually manage DB
fields● phpMyAdmin● mysql < changes.sql● ...
Symfony - heavyPost-deployment tasks:● cache:clear● cache:warmup● assets:install● assetic:dump● doctrine:migrations:migrate● restart some services● ...
Goals for solid deployment
● One-click deployment● Deploy in one transaction● Rollback● Automated tasks● Notifications● 0 downtime● Confidence
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
Why Capifony?● Fully supports Symfony features● Actively maintained since 2009● 6 active contributors● >100 total● last commit 16 days ago
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
$ 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...
Deploying with migrations:
$ cap deploy:migrations
Rolling-back migrations:
$ cap symfony -S task_arguments="doctrine:migrations:migrate 20150205170707 --no-interaction"
$ cap deploy:migrations
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
Multistage extensionEnables deployment to multiple servers$ cap STAGE_NAME deploy
Multistage extension:https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
Deploying release package● CI server builds release package (zip)● Capifony deploys
Capistrano deploy strategy called “archive”:https://github.com/sorccu/capistrano-deploy-strategy-archive
Other deployment tools● Fabric (Python)● Idephix● Magellanes● Deployer● Laravel / Envoy● Rocketeer● Ansible + Tower