Upcoming SlideShare
Loading in...5

Symfony 2 under control



Symfony Camp 2013 UA.

Symfony Camp 2013 UA.
Continuous Integration and Automated Deployments for Symfony-based projects

P.S. Original PPTX presentation contains a lot of notes



Total Views
Views on SlideShare
Embed Views



3 Embeds 301

http://blog.maxromanovsky.com 292
http://www.slideee.com 8
https://7549539176012236135_388ff553fa64c4e1c017d0f48149781636aa967c.blogspot.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

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.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • Speech includes not only slides and copy-paste from manual, but also a real practice P.S. A lot of well-known demotivators and gags are included)
  • практика разработки программного обеспечения, которая заключается в выполнении частых автоматизированных сборок проекта для скорейшего выявления и решения интеграционных проблем <br />
  • envs: dev/ci/qa/staging/uat/production
  • What to build? <br /> Install vendors <br /> Perform static analysis& validation <br /> Prepare assets <br /> Run tests <br /> Compress into archive
  • Ant: From Java world, XML declarative config, Can run tasks in parallel, No PHP-specific tasks, Could be extended (Java), IDE support <br /> Phing: Written in PHP, Ant config syntax, All tasks by default are running in the single PHP process, Could be extended (PHP), IDE support <br /> Pake: Written in PHP, Not so popular, PHP-based config <br /> Quiz: which tool is used by audience? <br />
  • Target: Could depend on other targets, phing <br /> Task: Custom tasks can be implemented, examples <br /> Types: Reference, FileSet, Property, FileList, Filters <br /> <br />
  • list-updates = composer update –dry-run <br /> security-checker = security.sensiolabs.org <br /> <br />
  • phpcs with custom configs for php & javascript <br />
  • Regular: Copy config for CI server, warmup cache, install assets & dump them via Assetic <br /> DB-related: drop & re-create DB, run Doctrine Migrations, load fixtures, validate DB schema. dump schema to DDL file <br /> twig:lint for Bundles and app/Resources <br />
  • Package: Add version to text file, add DDL schema schema.sql, package app, src, vendors, web to tar.gz <br /> Deployment (for specific Capifony subtasks: maintenance mode, backup DB, cleat Doctrine cache, cleanup old releases, deploy artifact)
  • Jenkins CI – ex-Hudson CI <br /> CruiseControl + PHP Under Control <br /> TeamCity, Bamboo: commercial <br /> Travis CI, Scrutinizer CI: SAAS <br /> Quiz: which tool is used by audience? <br />
  • git: disable internal tagging! <br /> copyartifact: copy artifact from one job to another <br /> email-ext: sends emails on successful builds, useful for deployment jobs <br /> <br /> <br />
  • phing <br /> checkstyle phpcs, hphpa <br /> dry phpcpd <br /> jdepend php_depend <br /> plot phploc using CSV files <br /> pmd phpmd <br /> violations aggregates info from phpcs, hphpa, phpmd, phpcpd <br /> xunit phpunit <br /> htmlpublisher HTML artifacts <br />
  • build-: Builds specific branch (master), Features are verified after merge <br /> build-package-tag: Parameterizedm Produces .tar.gz artifact from specific Git tag <br />
  • deploy-qa-: tar.gz from latest revision of branch, Deploys to QA, Not recommended to have more than one such job (issues with migrations), Workaround: multiple QA or complete DB purge on deploy <br /> deploy-package-tag: Deploys specific package from build-package-tag to specified environment, Ability to enable/disable maintenance mode and error message via parameters, Email after deployment <br /> <br /> <br />
  • Previous deployed version examples: . = v0.0.3.26, ---SNAPSHOT = master-12-7c041a90366ce9d958760094c763d809ffbc629e-SNAPSHOT <br />
  • Capistrano: from Ruby world <br /> Capifony: Based on Capistrano, Implemented in liip/symfony-rad-edition <br /> Custom: deb, rpm / VCS update / Rsync, FTP, SCP / Shell script <br /> Phar: Don’t use WebPhar, Silex does not use it anymore <br /> Zend Server package: No support for vanilla PHP, Zend Continuous Delivery Blueprint <br /> PaaS: AWS Elastic Beanstalk, PagodaBox <br /> <br /> Quiz: which tool is used by audience?
  • Capistrano: from Ruby world <br /> Capifony: Based on Capistrano, Implemented in liip/symfony-rad-edition <br /> Custom: deb, rpm / VCS update / Rsync, FTP, SCP / Shell script <br /> Phar: Don’t use WebPhar, Silex does not use it anymore <br /> Zend Server package: No support for vanilla PHP, Zend Continuous Delivery Blueprint <br /> PaaS: AWS Elastic Beanstalk, PagodaBox <br /> <br /> Quiz: which tool is used by audience?
  • Based on Capistrano: Supports Capistrano plugins <br />
  • Sometimes there is no access to internet due to security limitations
  • Decreases deployment time: Lot of vendors, Slow internet connection
  • Reproducible: You know what you deploy, You can deploy exactly the same package to multiple environments <br /> Quick fixes (git commit + git pull) not available <br />
  • pros / contras of maintenance mode <br /> <br /> 24x7 <br /> + users always have good UX (some functionality could be disabled / read only), ~99.999% uptime <br /> $$$ (implementation, testing, support & maintenance, hardware resources) <br /> complexity
  • User Triggers job on Jenkins CI, Choose options (env, maintenance mode) <br /> Jenkins Executes phing target with additional CLI arguments <br /> Phing Executes several Capifony commands according to command-line arguments <br /> Capifony Performs actions on remote machines <br />
  • Maintenance mode maintenance.html in webroot <br /> Clear Doctrine cache Not for APC cache <br /> Downloads previous deploy metadata package version, Doctrine Migrations info <br />
  • Restarts services: php-fpm or Apache, Doctrine APC cache is cleared <br /> Symfony-specific tasks: copy app/config/parameters.yml, doctrine:migrations:migrate, cache:warmup <br />
  • Housekeeping: Perform cleanup for old releases <br />
  • Semi-automatical: from deployment server, usually CI server <br /> Enable Maintenance: manually via phing <br /> Manually backup for analysis: DB, current version, Doctrine Migrations status, codebase <br />
  • Switch to previous release: Manually via capifony CLI <br /> Recover DB: Rollback Doctrine Migrations, Restore DB dump, Custom <br /> Additional tasks: Restore web server config, Restart service, cache:warmup <br /> Disable Maintenance Manually via phing <br />
  • Write rollback guide: Step-by-step, Verify it periodically <br /> Enable monitoring on prod: Zabbix, Pinba, Munin, New Relic, Graylog2 <br />

Symfony 2 under control Symfony 2 under control Presentation Transcript

  • Continuous Integration and Automated Deployments for Symfony-based projects Symfony 2 under control
  • Whois 2
  • Batteries ARE Included  4
  • For standard projects Phing Jenkins CI Capifony Quick facts 5
  • Open Source Bundle Quick facts 6
  • What is Continuous Integration? 7
  • Improve quality Understand current situation Automate checklists Notify colleagues How could it help you? 8
  • composer require "epam/ci- bundle=1.0.*" //update AppKernel app/console epam-ci:init "Acme Demo Project" How to use? 9
  • •Tweak configuration •Install tools on envs •… •Profit! How to use? 10
  • BUILD 11
  • Mmm… Build! 12
  • Ant Phing Pake Build tools 13
  • Target •Set of tasks Task •Action Types •Data types Phing Terminology 14
  • build-epam-ci.xml •Default workflow build.xml •Overwrites Phing build files 15
  • build.properties.dist •Project config build.properties •Environment config Phing config files 16
  • build •dev env •console build-ci •CI env •XML Main Phing Targets 17
  • package • tar.gz package • DDL dump deploy • packageenv Main Phing Targets 18
  • All Phing targets? 19
  • Phing. Want more? 20
  • clean prepare build-tools-self-update Phing Targets. Special 21
  • validate install list-updates security-checker Phing Targets. Composer 22
  • phplint pdepend phpmd Phing Targets. Static analysis 23
  • apidoc phpcs php-cs-fixer Phing Target. General 24
  • Phing Targets. General, by Sebastian Bergmann 25
  • Regular build workflow DB tasks twig:lint Phing Targets. Symfony-specific 26
  • Package Deployment Phing Targets. Deployment 27
  • CI servers 29
  • Open-source Enterprise Jenkins CI overview 30
  • Tons of plugins PHP Template by Sebastian Bergmann Jenkins CI overview 31
  • IDE Integration RESTful API Jenkins CI overview 32
  • Jenkins CI RESTful API http://habrahabr.ru/post/169097/ 33
  • git greenballs parameterized- trigger copyartifact email-ext Jenkins Plugins (common) 34
  • phing checkstyle dry jdepend plot pmd violations xunit htmlpublisher Jenkins Plugins (PHP-specific) 35
  • build-<branchname> build-package-tag Jenkins Jobs for build 36
  • deploy-qa-<branchname> deploy-package-tag Jenkins Jobs for deployment 37
  • Deployed .tar.gz archive Previous deployed version DB dump before deployment Doctrine Migrations info DB schema Jenkins Jobs for deployment. Artifacts Icons by http://dryicons.com 38
  • Deployment strategy 40
  • Custom Zend Server package PaaS Deployment tools 41
  • Phar Capistrano Capifony Deployment tools 42
  • Based on Capistrano Symfony 1 & 2 Capifony 43
  • Multistage Maintenance mode Clustered environments Capifony 44
  • Directory structure 45
  • releases/ current/ (symlink) shared/ Directory structure 46
  • app/config/parameters.yml app/logs web/uploads Directory structure / Shared 47
  • ln -s not shared across nodes Directory structure / Shared 48
  • `-- /var/www/my-app.com |-- current → /var/www/my-app.com/releases/20100512131539 |-- releases | `-- 20100512131539 | `-- 20100509150741 | `-- 20100509145325 `-- shared |-- web | `-- uploads |-- logs `-- config `-- parameters.yml Directory structure example from http://capifony.org/#4_setup_server 49
  • All you need is package capistrano-deploy- strategy-archive Deployment via SCM vs package 50
  • Deployment via SCM vs package: Github not available? Goodbye, vendors! 51
  • Decreases deployment time Increases build time Deployment via SCM vs package 52
  • Reproducible Quick fixes not available Deployment via SCM vs package 53
  • .tar.gz Optimized autoloader only necessary dirs & files Package contents 54
  • assets:install assetic:dump version.txt & db-schema.sql Package contents 55
  • DBDeploy Liquibase Doctrine Migrations Doctrine Fixtures Database Migrations 56
  • Deployment: Maintenance mode 57
  • User Jenkins Phing Capifony Capifony & Jenkins CI 58
  • Maintenance mode on Backup DB Clear Doctrine cache Download previous build metadata Capifony & Phing. Deployment preparations 59
  • Deploy tar.gz package Restart services Symfony-specific tasks Capifony & Phing. Deployment 60
  • Maintenance mode off Housekeeping Capifony & Phing. Post-deployment steps 61
  • Broken build??? 62
  • Enable Maintenance Manually backup for analysis Rollback is semi-automatic 63
  • Switch to previous release Additional tasks Disable Maintenance Rollback 64
  • Write rollback guide Enable monitoring on prod Rollback tips 65
  • P.S. 66
  • Build • Static analysis via HHVM • Actually was implemented, but hphpa changed a lot (now it’s https://github.com/sebastianbergmann/hhvm- wrapper) Deployment • Cronjob / CLI script handling • Web server (Apache, nginx) config manipulations • Ext- and lib- dependency verification via Composer • Custom script execution during deployment What is not implemented yet 67
  • Questions?