SlideShare a Scribd company logo
1 of 16
Yury Pliashkou 
CTO, IdeaSoft 
pliashkou@gmail.com 
Minsk, 2014
Requirements: 
ruby, rubygems 
Installation: 
gem install capifony 
Setup project: 
cd path/to/your/project 
capifony .
Deployment strategies: deployment → scm → production 
# deploy.rb 
set :application, "My App" 
set :deploy_to, "/var/www/my-app.com" 
set :domain, "my-app.com" 
set :scm, :git 
set :repository, "ssh-gitrepo-domain.com:/path/to/repo.git" 
role :web, domain 
role :app, domain, :primary => true 
set :use_sudo, false 
set :keep_releases, 3
Deployment strategies: deployment → scm → production 
In this case, on every cap deploy, capifony will: 
● ssh to production (my-app.com) 
● create a new release path (/var/www/my-app.com/releases/...) 
● clone the latest project version from the remote git repo (ssh-gitrepo- 
domain.com) 
● copy the source code, pulled from git, into the release path 
● run deployment hooks (cache:warmup, cc, etc.)
Deployment strategies: deployment → production (via copy) 
# deploy.rb 
set :application, "My App" 
set :deploy_to, "/var/www/my-app.com" 
set :domain, "my-app.com" 
set :scm, :git 
set :repository, "file:///Users/deployer/sites/my-app" 
set :deploy_via, :copy 
role :web, domain 
role :app, domain, :primary => true 
set :use_sudo, false 
set :keep_releases, 3
Deployment strategies: deployment → production (via copy) 
In this case, on every cap deploy, capifony will: 
● ssh to production (my-app.com) 
● create a new release path (/var/www/my-app.com/releases/...) 
● clone the latest project version from the local git repo 
● copy the source code, pulled from git, onto the production 
server via wires 
● run deployment hooks (cache:warmup, cc, etc.) 
Deploy is very expensive and slow! Solution: 
gem install capistrano_rsync_with_remote_cache 
set :deploy_via, :rsync_with_remote_cache
Setup server: 
cap deploy:setup 
This command will create the following approximate directory structure : 
`-- /var/www/my-app.com 
|-- current → /var/www/my-app. 
com/releases/20100512131539 
|-- releases 
| `-- 20100512131539 
| `-- 20100509150741 
| `-- 20100509145325 
`-- shared 
|-- web 
| `-- uploads 
|-- log 
`-- config 
`-- databases.yml
Deploy! 
cap deploy 
Something went wrong??? 
cap deploy:rollback
Symfony2 Deployment 
First, add the following to your app/config/deploy.rb file so 
that theparameters.yml file is shared between all 
deployments: 
set :shared_files, ["app/config/parameters.yml"] 
Next, share the vendor directory between all deployments to make deploying 
faster: 
set :shared_children, [app_path + "/logs", web_path + "/uploads", "vendor"] 
To install your vendors, capifony will rely on bin/vendors by default. But the 
recommended dependency manager is now Composer. In order to use it, just add 
the following configuration: 
set :use_composer, true 
set :update_vendors, true
Useful Tasks 
If you need to deploy and run your migrations you can call: 
cap deploy:migrations 
To run your test suite on the production server, just invoke: 
cap deploy:test_all 
You can invoke tasks/commands by calling: 
cap symfony 
If you want to see all available tasks, you can run: 
cap -vT
Symfony 2 Configuration Reference 
All symfony tasks run using the default php binary on the production 
server. You can change this via: 
set :php_bin, "/path/to/php" 
All symfony tasks also run inside the prod environment on production 
server. You can change this via: 
set :symfony_env_prod, "staging" 
If you use AsseticBundle with Symfony2, then you probably want to dump 
assets on every deploy: 
set :dump_assetic_assets, true
Recipe: Automatically set proper permissions 
set :writable_dirs, ["app/cache", "app/logs"] 
set :webserver_user, "www-data" 
set :permission_method, :acl 
set :use_set_permissions, true 
Recipe: Speeding up deploy 
before 'symfony:composer:install', 'composer:copy_vendors' 
before 'symfony:composer:update', 'composer:copy_vendors' 
namespace :composer do 
task :copy_vendors, :except => { :no_release => true } do 
run "vendorDir=#{current_path}/vendor; if [ -d $vendorDir ] || [ -h 
$vendorDir ]; then cp -a $vendorDir #{latest_release}/vendor; fi;" 
end 
end
Recipe: How to keep Symfony2 sessions after deploy 
In order to change sessions save path change the save_path parameter 
under a framework node in your application’s config.yml 
framework: 
session: 
save_path: "%kernel.root_dir%/sessions/" 
You have to add also your sessions directory to Capifony’s :shared_children 
# deploy.rb 
set :shared_children, [log_path, ..., app_path + "/sessions"]
Recipe: Working with databases 
Dump remote database, and download this dump to local backups/ folder: 
cap database:dump:remote 
Dump local database, and put this dump to local backups/ folder: 
cap database:dump:local 
Dump remote database, and populate this dump on local machine: 
cap database:copy:to_local 
Dump local database, and populate this dump on remote server: 
cap database:copy:to_remote
Demo
Questions ? 
Yury Pliashkou 
CTO, IdeaSoft 
pliashkou@gmail.com

More Related Content

What's hot

How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stackRootGate
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to AnsibleDan Vaida
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPressdotCloud
 
Cloud focker を試してみた public
Cloud focker を試してみた   publicCloud focker を試してみた   public
Cloud focker を試してみた publicTakehiko Amano
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command linedotCloud
 
Deployment with capistrano
Deployment with capistranoDeployment with capistrano
Deployment with capistranosagar junnarkar
 
Quickly extending into testing with docker
Quickly extending into testing with dockerQuickly extending into testing with docker
Quickly extending into testing with dockerTom Cudd
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Conrad Cruz
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringConrad Cruz
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year laterChristian Ortner
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltStack
 
NLIT 2011: Chef & Capistrano
NLIT 2011: Chef & CapistranoNLIT 2011: Chef & Capistrano
NLIT 2011: Chef & Capistranonickblah
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoBrian Hogan
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and ChefDavid Benjamin
 

What's hot (19)

Capistrano 3 Deployment
Capistrano 3 DeploymentCapistrano 3 Deployment
Capistrano 3 Deployment
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
Cloud focker を試してみた public
Cloud focker を試してみた   publicCloud focker を試してみた   public
Cloud focker を試してみた public
 
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command lineInstalling and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
 
Watch Me Install Alfresco
Watch Me Install AlfrescoWatch Me Install Alfresco
Watch Me Install Alfresco
 
Deployment with capistrano
Deployment with capistranoDeployment with capistrano
Deployment with capistrano
 
Quickly extending into testing with docker
Quickly extending into testing with dockerQuickly extending into testing with docker
Quickly extending into testing with docker
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Capistrano
CapistranoCapistrano
Capistrano
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
 
NLIT 2011: Chef & Capistrano
NLIT 2011: Chef & CapistranoNLIT 2011: Chef & Capistrano
NLIT 2011: Chef & Capistrano
 
體驗 Hhvm
體驗 Hhvm體驗 Hhvm
體驗 Hhvm
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with Hugo
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and Chef
 

Similar to Capifony. Minsk PHP MeetUp #11

Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf Conference
 
Deploying Rails applications with Moonshine
Deploying Rails applications with MoonshineDeploying Rails applications with Moonshine
Deploying Rails applications with MoonshineRobot Mode
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard DevelopersHenri Bergius
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient waySylvain Rayé
 
macos installation automation
macos installation automationmacos installation automation
macos installation automationJon Fuller
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on DockerDaniel Ku
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with CapistranoRamazan K
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Varnish Configuration Step by Step
Varnish Configuration Step by StepVarnish Configuration Step by Step
Varnish Configuration Step by StepKim Stefan Lindholm
 
AWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAnton Babenko
 
Node.js basics
Node.js basicsNode.js basics
Node.js basicsBen Lin
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyAndré Rømcke
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 DevelopmentDuke Dao
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 

Similar to Capifony. Minsk PHP MeetUp #11 (20)

Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Composer
ComposerComposer
Composer
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 
Deploying Rails applications with Moonshine
Deploying Rails applications with MoonshineDeploying Rails applications with Moonshine
Deploying Rails applications with Moonshine
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
macos installation automation
macos installation automationmacos installation automation
macos installation automation
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
MeaNstack on Docker
MeaNstack on DockerMeaNstack on Docker
MeaNstack on Docker
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Varnish Configuration Step by Step
Varnish Configuration Step by StepVarnish Configuration Step by Step
Varnish Configuration Step by Step
 
IOS 11 setup with appium latest
IOS 11 setup with appium  latestIOS 11 setup with appium  latest
IOS 11 setup with appium latest
 
AWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAWS CodeDeploy - basic intro
AWS CodeDeploy - basic intro
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
Running Symfony
Running SymfonyRunning Symfony
Running Symfony
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 

Recently uploaded

Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 

Recently uploaded (11)

Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 

Capifony. Minsk PHP MeetUp #11

  • 1. Yury Pliashkou CTO, IdeaSoft pliashkou@gmail.com Minsk, 2014
  • 2. Requirements: ruby, rubygems Installation: gem install capifony Setup project: cd path/to/your/project capifony .
  • 3. Deployment strategies: deployment → scm → production # deploy.rb set :application, "My App" set :deploy_to, "/var/www/my-app.com" set :domain, "my-app.com" set :scm, :git set :repository, "ssh-gitrepo-domain.com:/path/to/repo.git" role :web, domain role :app, domain, :primary => true set :use_sudo, false set :keep_releases, 3
  • 4. Deployment strategies: deployment → scm → production In this case, on every cap deploy, capifony will: ● ssh to production (my-app.com) ● create a new release path (/var/www/my-app.com/releases/...) ● clone the latest project version from the remote git repo (ssh-gitrepo- domain.com) ● copy the source code, pulled from git, into the release path ● run deployment hooks (cache:warmup, cc, etc.)
  • 5. Deployment strategies: deployment → production (via copy) # deploy.rb set :application, "My App" set :deploy_to, "/var/www/my-app.com" set :domain, "my-app.com" set :scm, :git set :repository, "file:///Users/deployer/sites/my-app" set :deploy_via, :copy role :web, domain role :app, domain, :primary => true set :use_sudo, false set :keep_releases, 3
  • 6. Deployment strategies: deployment → production (via copy) In this case, on every cap deploy, capifony will: ● ssh to production (my-app.com) ● create a new release path (/var/www/my-app.com/releases/...) ● clone the latest project version from the local git repo ● copy the source code, pulled from git, onto the production server via wires ● run deployment hooks (cache:warmup, cc, etc.) Deploy is very expensive and slow! Solution: gem install capistrano_rsync_with_remote_cache set :deploy_via, :rsync_with_remote_cache
  • 7. Setup server: cap deploy:setup This command will create the following approximate directory structure : `-- /var/www/my-app.com |-- current → /var/www/my-app. com/releases/20100512131539 |-- releases | `-- 20100512131539 | `-- 20100509150741 | `-- 20100509145325 `-- shared |-- web | `-- uploads |-- log `-- config `-- databases.yml
  • 8. Deploy! cap deploy Something went wrong??? cap deploy:rollback
  • 9. Symfony2 Deployment First, add the following to your app/config/deploy.rb file so that theparameters.yml file is shared between all deployments: set :shared_files, ["app/config/parameters.yml"] Next, share the vendor directory between all deployments to make deploying faster: set :shared_children, [app_path + "/logs", web_path + "/uploads", "vendor"] To install your vendors, capifony will rely on bin/vendors by default. But the recommended dependency manager is now Composer. In order to use it, just add the following configuration: set :use_composer, true set :update_vendors, true
  • 10. Useful Tasks If you need to deploy and run your migrations you can call: cap deploy:migrations To run your test suite on the production server, just invoke: cap deploy:test_all You can invoke tasks/commands by calling: cap symfony If you want to see all available tasks, you can run: cap -vT
  • 11. Symfony 2 Configuration Reference All symfony tasks run using the default php binary on the production server. You can change this via: set :php_bin, "/path/to/php" All symfony tasks also run inside the prod environment on production server. You can change this via: set :symfony_env_prod, "staging" If you use AsseticBundle with Symfony2, then you probably want to dump assets on every deploy: set :dump_assetic_assets, true
  • 12. Recipe: Automatically set proper permissions set :writable_dirs, ["app/cache", "app/logs"] set :webserver_user, "www-data" set :permission_method, :acl set :use_set_permissions, true Recipe: Speeding up deploy before 'symfony:composer:install', 'composer:copy_vendors' before 'symfony:composer:update', 'composer:copy_vendors' namespace :composer do task :copy_vendors, :except => { :no_release => true } do run "vendorDir=#{current_path}/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir #{latest_release}/vendor; fi;" end end
  • 13. Recipe: How to keep Symfony2 sessions after deploy In order to change sessions save path change the save_path parameter under a framework node in your application’s config.yml framework: session: save_path: "%kernel.root_dir%/sessions/" You have to add also your sessions directory to Capifony’s :shared_children # deploy.rb set :shared_children, [log_path, ..., app_path + "/sessions"]
  • 14. Recipe: Working with databases Dump remote database, and download this dump to local backups/ folder: cap database:dump:remote Dump local database, and put this dump to local backups/ folder: cap database:dump:local Dump remote database, and populate this dump on local machine: cap database:copy:to_local Dump local database, and populate this dump on remote server: cap database:copy:to_remote
  • 15. Demo
  • 16. Questions ? Yury Pliashkou CTO, IdeaSoft pliashkou@gmail.com