continous php pipeline - zendcon 2014
DESCRIPTION
You've got your tests, your metrics, your database migrations and your system provisioning automated, but how can you deploy everything with a push of a button and not be scared something goes wrong? Welcome to the continuous PHP Pipeline. In this talk I take the code, the tests, the metrics and the provisioners and show you how you can have a continuous delivery pipeline setup based on certain criteria you define upfront, your code gets automatically deployed to staging or to production with all the arbitrary tasks along with it. Never get stressed again about deployments. Make deployments as easy as committing to your repository and get home on time to enjoy your well deserved weekend.TRANSCRIPT
2
The Con(nuous PHP PipelineZendCon 2014, Santa Clara
Michelangelo van Dam
2
Schedule
• Development processes • Automa;on first • Con;nuous Integra;on • The PHP Pipeline • Do what you do best: code • Round up
3
Required knowledge
• Working with an SCM • Unit tes;ng • Distributed architectures • Provisioning plaMorms • Have experienced troubled releases
4
Development management
5
http
s://w
ww.
flick
r.com
/pho
tos/
2743
3628
@N
05/2
5973
0832
8
Project flow: Waterfall
6
Project Start
Kick-off meetingDefining Approach
Meeting Execs
Project Initiate
Business CasesProject ControlsRisk Definition
Project Control
Progress Monitoring
Project Delivery
Project finalisation
Maintenance
Ongoing process
Project flow: Scrum
7
Weeklybacklog review
Dailystandups
Product Backlog
AcceptanceCriteria
Sprint Backlog Prototype Delivery
Product Backlog
Product BacklogProduct
Backlog
Sprint
Project flow: something…
8
Project Requirements
Ad-hockIssues
TaskAssignment Delivery
Common: delivery
9
Weeklybacklog review
Dailystandups
Product Backlog
AcceptanceCriteria
Sprint Backlog Prototype Delivery
Product Backlog
Product BacklogProduct
Backlog
Sprint
Project Start
Kick-off meetingDefining Approach
Meeting Execs
Project Initiate
Business CasesProject ControlsRisk Definition
Project Control
Progress Monitoring
Project Delivery
Project finalisation
Maintenance
Ongoing process
Project Requirements
Ad-hockIssues
TaskAssignment Delivery
Delivery
Delivery event!
• Off-‐hours release planning • Set up a maintenance page • Pre-‐release ac;ons (backups, stopping crons, …) • Release checklist -‐> manual deployment • Post-‐release ac;ons (crons, caches, …) • Removing maintenance page • Manually verify everything is working (old & new stuff) • If lucky, going home for the night
10
A nightmare
11
http
s://w
ww.
flick
r.com
/pho
tos/
bern
atcg
/223
1649
285
Automa(on first!
12
http
s://w
ww.
flick
r.com
/pho
tos/
freef
oto/
5982
5499
38
Computers are great at doing repe((ve task very well
13
Iden(fying the players
14
Development
Source Code
Static Files
Database Deltas
Platform
Monitoring Database
Storage Workers Caches
Web Server
Infrastructure
Bare Metal
Virtual Machines Cloud
Infrastructure
15
Infrastructure
Bare Metal
Virtual Machines Cloud
PlaJorm
16
Platform
Monitoring Database
Storage Workers Caches
Web Server
Automa(ng tools
17
https://www.gnu.org/graphics/heckert_gnu.small.png
Why automate plaJorm?
• It should be op;mised to run your applica;on • Con;nuous updates and tweaks possible • SeXng up your architecture in a consistent way
• For produc;on • For staging • For tes;ng • For development
18
Choose wisely
19
http
s://w
ww.
flick
r.com
/pho
tos/
keep
itsur
real
/610
7919
083
Give Docker a try
• Requires no virtualisa;on so[ware • Saves on resources!
• Allows to set up a distributed architecture • Even for development purposes
• Isolates processes in a container • Helps with securing infrastructure
20
Vagrant up
21
Monitoring Database
Storage Workers Caches
Web Server
Development
22
Development
Source Code
Static Files
Database Deltas
SCM is a must!
23
FTP is not SCM!!!
24
Commit and push
25
Con(nuous Integra(on
26
http
s://w
ww.
flick
r.com
/pho
tos/
mab
i/383
0712
4
Most common CI systems
27
Why CI?
• Monitors con;nuously • Executes directly a[er change • Gives feedback • Has dashboards • Automate post-‐development processes
28
http
s://w
ww.
flick
r.com
/pho
tos/
ambe
rand
clin
t/326
6859
324
CI takes care of you
29
Pre build steps!- Stop crons, queues and workers - Remove target from load balancer
Build steps!- Check out new changes - Run unit tests - Provision target(s) - Provision databases
Post build steps!- Warm up caches - Reactivate crons, queues and workers - Add target back into loadbalancer - Sent status out
The PHP Pipeline
30
http
s://w
ww.
flick
r.com
/pho
tos/
mm
mav
ocad
o/45
9739
7875
Priori(se build steps
31
Unit tests Metrics
Provisioningnew target
Provisioningdatabases
Provisioningworkers
Integrationtests
Promotebranch
CI
Stop execu(on at first fail
32
Unit tests Metrics
Provisioningnew target
Provisioningdatabases
Provisioningworkers
Integrationtests
Promotebranch
CI
When good, promote
33
Unit tests Metrics
Provisioningnew target
Provisioningdatabases
Provisioningworkers
Integrationtests
Promotebranch
CI
Unit tests Metrics
Provisioningnew target
Provisioningdatabases
Provisioningworkers
Integrationtests
Promotebranch
CI
Con(nuous Delivery
34
Build Feedback
Build Feedback
SCMCommits SCM Change
Polling
Deployment ManagementDashboard
test
staging
production
Con(nuous Deployment
35
Build Feedback
Execute Delivery
SCMCommits SCM Change
Pollingtest
staging
production
What’s the difference?
36
Source: http://blog.crisp.se/2013/02/05/yassalsundman/continuous-delivery-vs-continuous-deployment
Do what you do best: code!
37
http
s://w
ww.
flick
r.com
/pho
tos/
ihta
tho/
6272
2631
5
The benefit
38
Failures happen
39
Overview of our tools
40
Rounding up
41
http
s://w
ww.
flick
r.com
/pho
tos/
timyp
enbu
rg/5
1720
4200
7
Build your own pipeline
• Automate everything that’s not coding • Create repeatable, reliable processes • Fail as quickly as possible
• If it hurts, do it more frequently • Communicate each step
• Everyone is responsible! • Con;nuously improve
• On your code • On your processes
42
44
45
joind.in/12053
Slides will be available here, please leave feedback !
If you like it, thanks! If you don’t, tell me how to improve this talk
Ques(ons?
46
Thank you
47
in it2PROFESSIONAL PHP SERVICES
Michelangelo van Dam!Zend Certified Engineer
PHP Consulting - Training - Quality Assurance
www.in2it.be | [email protected]