Symfony 2 under control
-
Upload
max-romanovsky -
Category
Software
-
view
393 -
download
1
description
Transcript of Symfony 2 under control
Continuous Integration and Automated Deployments for Symfony-based projects
Symfony 2 under control
2
[email protected][email protected], Twitter,Github, LinkedIn,MoiKrug,SensioLabs Connect:maxromanovsky
Whois
3
INTRODUCTION
4
Batteries ARE Included
5
For standard projects Phing
Jenkins CI Capifony
Quick facts
6
Open Source
Bundle
Quick facts
7
What is Continuous Integration?
8
Improve quality
Understand current
situation
Automate checklists
Notify colleagues
How could it help you?
9
composer require "epam/ci-
bundle=1.0.*"
//update AppKernel
app/console epam-ci:init
"Acme Demo Project"
How to use?
10
•Tweak configuration•Install tools on envs•…•Profit!
How to use?
11
BUILD
12
Mmm… Build!
13
Ant Phing
Pake
Build tools
14
Target
•Set of tasks
Task
•Action
Types
•Data types
Phing Terminology
15
build-epam-ci.xml
• Default workflow
build.xml
• Overwrites
Phing build files
16
build.properties.dist
• Project config
build.properties
• Environment config
Phing config files
17
build
•dev env•console
build-ci
•CI env•XML
Main Phing Targets
18
package
• tar.gz package• DDL dump
deploy
• packageenv
Main Phing Targets
19
phing -lAll Phing targets?
20
Phing. Want more?
21
clean
prepare
build-tools-self-update
Phing Targets. Special
22
validate
install
list-updates
security-checker
Phing Targets. Composer
23
phplint pdepend
phpmd
Phing Targets. Static analysis
24
apidoc phpcs
php-cs-fixer
Phing Target. General
25
phpunit
phplocphpcpd
Phing Targets. General, by Sebastian Bergmann
26
Regular build workflow
DB tasks
twig:lint
Phing Targets. Symfony-specific
27
Package
Deployment
Phing Targets. Deployment
28
CONTINUOUS INTEGRATION
29
CI servers
30
Open-source
Enterprise
Jenkins CI overview
31
Tons of plugins
PHP Template by Sebastian Bergmann
Jenkins CI overview
32
IDE Integration
RESTful API
Jenkins CI overview
34
git greenballs
parameterized-trigger
copyartifact
email-ext
Jenkins Plugins (common)
35
phing checkstyle dry
jdepend plot pmd
violations xunit htmlpublisher
Jenkins Plugins (PHP-specific)
36
build-<branchname>
build-package-tag
Jenkins Jobs for build
37
deploy-qa-<branchname>
deploy-package-tag
Jenkins Jobs for deployment
38
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
39
DEPLOYMENT
40
Deployment strategy
41
Custom Zend Server package
PaaS
Deployment tools
42
Phar Capistrano
Capifony
Deployment tools
43
Based on Capistrano
Symfony 1 & 2
Capifony
44
Multistage
Maintenance mode
Clustered environments
Capifony
45
Directory structure
46
releases/
current/ (symlink)
shared/
Directory structure
47
app/config/parameters.yml
app/logs
web/uploads
Directory structure / Shared
48
ln -s
not shared across nodes
Directory structure / Shared
49
`-- /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
50
All you need is package
capistrano-deploy-strategy-archive
Deployment via SCM vs package
51
Deployment via SCM vs package: Github not available? Goodbye, vendors!
52
Decreases deployment time
Increases build time
Deployment via SCM vs package
53
Reproducible
Quick fixes not available
Deployment via SCM vs package
54
.tar.gz
Optimized autoloader
only necessary dirs & files
Package contents
55
assets:install
assetic:dump
version.txt & db-schema.sql
Package contents
56
DBDeploy Liquibase
Doctrine Migrations
Doctrine Fixtures
Database Migrations
57
Deployment: Maintenance mode
58
User Jenkins Phing Capifony
Capifony & Jenkins CI
59
Maintenance mode on
Backup DB
Clear Doctrine cache
Download previous build metadata
Capifony & Phing. Deployment preparations
60
Deploy tar.gz package
Restart services
Symfony-specific tasks
Capifony & Phing. Deployment
61
Maintenance mode off
Housekeeping
Capifony & Phing. Post-deployment steps
62
Broken build???
63
Enable Maintenance
Manually backup for analysis
Rollback is semi-automatic
64
Switch to previous release
Additional tasks
Disable Maintenance
Rollback
65
Write rollback guide
Enable monitoring on prod
Rollback tips
66
P.S.
67
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
Questions?