Top Banner
Deployment Is Not A Four Letter Word Chris Hartjes PHP Quebec 2009 Conference
48

Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Jul 09, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Deployment Is NotA Four Letter Word

Chris HartjesPHP Quebec 2009 Conference

Page 2: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

WARNING: This presentation may contain language that is offensive to some. I’ll try not to

swear but sometimes it just comes out...

Page 3: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

A little bit about myself...

Page 4: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

(I work from home for)

Page 5: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

What I use every day

Page 6: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and
Page 7: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

(completely unscientific but it sure feels that way)

http://blog.heroku.com/archives/2009/2/23/why_instant_deployment_matters/

Page 8: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

VS.

Page 9: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Chris’ 6 Rules for Confident Deployment

Page 10: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #1

It’s not the first time you deploy that

hurts. It’s the first time you change what’s already there and it breaks that

it hurts.

Page 11: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Your Deployment Tool Should Run Your Tests

(but if it can’t, run them yourself)

PHPT

Page 12: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Sometimes testing is hard...

Page 13: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Learn how to use your VCS hooks

Page 14: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #2

If you can change your application in

production, you better be able to change it back to

the way it was

Page 15: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Version Control lets you roll changes back

Subversion

Mercurial

Git

CVS

Bazaar

Page 16: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

If You Can’t Automate The Checkout, Stop Using It

Your deployment tool has to be able to talk to your version

control...

...who owes hiscareer to theOpen Web

...so you are always getting your code from

the same place

Page 17: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Your Deployment Dynamic Duo

Page 18: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #3

Don’t forget that there is often more to your

application than just code

Page 19: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and
Page 20: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Managing Database Changes Is Critical

Tools should make

the changes for you...

... or write SQL scripts and put ‘em under version

control

Page 21: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Example of DB migrations in CakePHP

Page 22: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and
Page 23: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #4

If it’s not repeatable...and

automated...you’re wasting your time

Page 24: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Manual Deployment is For Suckers

Automating deployment of your

code...

...means one less thing for you to

screw up

Page 25: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Automation forces consistency across environments

Page 26: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

You can deploy it...

...and so can they

Page 27: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #5

The only difference in your application’s

environments should be the data sets

Page 28: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and
Page 29: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Consistency Is Not The Hobgoblin of Little

MindsBugs that “only

exist in production”...

...will never be found in

development

Page 30: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Tunnel through to your production resources

ssh -fNg -L3310:gerrit.lan:3306 gerrit@dbServerHost

Page 31: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Copy sample datasets to your development environment

Page 32: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Rule #6

Ownership of code means also having a stake

in making sure it gets deployed properly

Page 33: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Write Your Code To Your Environment

Your changes shouldn’t be so

difficult...

...that you’re the only one who can

make them

Page 34: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Some types of applications...

Page 35: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

...have their own deployment processes

Page 36: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Roll your own is popular...

...because everyone thinks they are unique

Page 37: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Very popular in the Java world...

... but only works for Java

Page 38: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

A lot like Maven and Ant...

...but all that XML is not friendly

Page 39: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Vlad the Deployer

Best.Name.Ever.

Sadly, only for Rails-based applications

Page 40: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Fabric

Python-based deployment...

...but documentation is

lacking

Page 41: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Works best with Rails...

...but can deploy almost anything

Page 42: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

# Deployment Settingsset :repository, "svn+ssh://[email protected]/opt/repos/sportso.com"set :deploy_to, "/var/www/#{application}" # This is where your project will be deployed.set :svn_user, 'chris'set :svn_password, 'password'

# Uncomment this if you want to deploy your project by copying# the files from your local computer.set :deploy_via, :copy

load 'deploy' if respond_to?(:namespace) # cap2 differentiatorrequire 'rubygems'

set :application, "sportso.com"set :domain, "hawks.xmlteam.com"role :app, domainrole :web, domainrole :db, domain, :primary => true

default_run_options[:pty] = true

# Set the Unix user and group that will actually perform # each task on the remote server. The defaults are set to # 'deploy'set :user, "user"set :group, "group"

Sample code from a Capistrano deployment recipe

Page 43: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

task :exist do run "cp /var/www/app/config/xql/*.xq* /opt/resin/webapps/exist/xquery/" end

Adding a task to copy XQuery scripts

Page 44: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Doesn’t care what you’re installing

Only needs SSH on remote

servers

One command can do it all!

Page 45: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

Some things Chris uses to make deployment easier

* deployment-only user accounts with proper permissions

* SSH login without passwords (using public key / private key)

* standardized locations for deployment

Page 46: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

So let’s go over Chris’ 6 Rules for confident deployments

Page 47: Deployment Is Not A Four Letter Wordchartjes-slides.s3.amazonaws.com/PHP Quebec 2009 - Deployment talk.pdfExample of DB migrations in CakePHP. Rule #4 If it’s not repeatable...and

1. It’s not the first time you deploy that hurts. It’s the first time you change what’s already there and it breaks that it hurts.

2. If you can change your application in production, you better be able to change it back to the way it was

5. The only difference in your application’s environments should be the data sets

4. If it’s not repeatable...and automated...you’re wasting your time

3. Don’t forget that there is often more to your application than just code

6. Ownership of code means also having a stake in making sure it gets deployed properly