drupal devdays barcelona 2012 – staging with git and drush

81
Staging with git & drush Dienstag, 7. Mai 13

Upload: markus-heurung

Post on 29-Nov-2014

863 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Drupal devdays barcelona 2012 – Staging with git and drush

Staging with git & drush

Dienstag, 7. Mai 13

Page 2: Drupal devdays barcelona 2012 – Staging with git and drush

freistil IT

Markus Heurung – @muhh

[email protected]

Dienstag, 7. Mai 13

Page 3: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 4: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

Dienstag, 7. Mai 13

Page 5: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

work

Dienstag, 7. Mai 13

Page 6: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

work

Dienstag, 7. Mai 13

Page 7: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

work

Dienstag, 7. Mai 13

Page 8: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

workfix

Dienstag, 7. Mai 13

Page 9: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

workfix

Dienstag, 7. Mai 13

Page 10: Drupal devdays barcelona 2012 – Staging with git and drush

„Deploying“ the old way

index.phpupdate.phpmodules/includes/sites/…

FTP

workfix

Dienstag, 7. Mai 13

Page 11: Drupal devdays barcelona 2012 – Staging with git and drush

multiple developers

index.phpupdate.phpmodules/includes/sites/…

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 12: Drupal devdays barcelona 2012 – Staging with git and drush

multiple developers

index.phpupdate.phpmodules/includes/sites/…

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 13: Drupal devdays barcelona 2012 – Staging with git and drush

multiple developers

index.phpupdate.phpmodules/includes/sites/…

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 14: Drupal devdays barcelona 2012 – Staging with git and drush

write-write conflict

multiple developers

index.phpupdate.phpmodules/includes/sites/…

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 15: Drupal devdays barcelona 2012 – Staging with git and drush

SUCKS!

Dienstag, 7. Mai 13

Page 16: Drupal devdays barcelona 2012 – Staging with git and drush

develop locally!

Dienstag, 7. Mai 13

Page 17: Drupal devdays barcelona 2012 – Staging with git and drush

XAMPP/MAMP

Acquia Dev Desktop

Linux

Mac OS X

Dienstag, 7. Mai 13

Page 18: Drupal devdays barcelona 2012 – Staging with git and drush

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 19: Drupal devdays barcelona 2012 – Staging with git and drush

index.phpupdate.phpmodules/includes/sites/…

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 20: Drupal devdays barcelona 2012 – Staging with git and drush

Version Control

Dienstag, 7. Mai 13

Page 21: Drupal devdays barcelona 2012 – Staging with git and drush

Git

Dienstag, 7. Mai 13

Page 22: Drupal devdays barcelona 2012 – Staging with git and drush

Repository

index.phpupdate.phpmodules/includes/sites/…

put your code into git

Dienstag, 7. Mai 13

Page 23: Drupal devdays barcelona 2012 – Staging with git and drush

Repository

index.phpupdate.phpmodules/includes/sites/…

put your code into git

Dienstag, 7. Mai 13

Page 24: Drupal devdays barcelona 2012 – Staging with git and drush

Some git basics

$ git add $FILE(S)$ git commit $FILE(S)

Dienstag, 7. Mai 13

Page 25: Drupal devdays barcelona 2012 – Staging with git and drush

some git basics

$ git add docroot/$ git commit docroot/

Dienstag, 7. Mai 13

Page 26: Drupal devdays barcelona 2012 – Staging with git and drush

the typical local git workflow

$ [work …]$ git commit -am "meaningful message"$ [work …]$ git add sites/all/modules/custom/stuff/$ git commit -am "added stuff module"

Dienstag, 7. Mai 13

Page 27: Drupal devdays barcelona 2012 – Staging with git and drush

Repository

index.phpupdate.phpmodules/includes/sites/…

put your code into git

Dienstag, 7. Mai 13

Page 28: Drupal devdays barcelona 2012 – Staging with git and drush

index.phpupdate.phpmodules/includes/sites/…

transfer commits

local integration

Dienstag, 7. Mai 13

Page 29: Drupal devdays barcelona 2012 – Staging with git and drush

git remote repositories

Dienstag, 7. Mai 13

Page 30: Drupal devdays barcelona 2012 – Staging with git and drush

working with remotes

$ git remote add integration \\ [email protected]:test.git

Dienstag, 7. Mai 13

Page 31: Drupal devdays barcelona 2012 – Staging with git and drush

transfer commits

$ git push integration$ git pull integration

Dienstag, 7. Mai 13

Page 32: Drupal devdays barcelona 2012 – Staging with git and drush

index.phpupdate.phpmodules/includes/sites/…

transfer commits

local integration

pull

push

Dienstag, 7. Mai 13

Page 33: Drupal devdays barcelona 2012 – Staging with git and drush

index.phpupdate.phpmodules/includes/sites/…

transfer commits

local integration

index.phpupdate.phpmodules/includes/sites/…

pull

push

Dienstag, 7. Mai 13

Page 34: Drupal devdays barcelona 2012 – Staging with git and drush

let the serverdeploy the code

to its docroot

Dienstag, 7. Mai 13

Page 35: Drupal devdays barcelona 2012 – Staging with git and drush

git knows hooks!

Dienstag, 7. Mai 13

Page 36: Drupal devdays barcelona 2012 – Staging with git and drush

.git/hooks/post-receive

→ go to docroot and do a git pull

Dienstag, 7. Mai 13

Page 37: Drupal devdays barcelona 2012 – Staging with git and drush

What about sites/*/files?

Dienstag, 7. Mai 13

Page 38: Drupal devdays barcelona 2012 – Staging with git and drush

not in git!

Dienstag, 7. Mai 13

Page 39: Drupal devdays barcelona 2012 – Staging with git and drush

$ echo "sites/*/files" >> .gitignore

let git ignore it

Dienstag, 7. Mai 13

Page 40: Drupal devdays barcelona 2012 – Staging with git and drush

drush

Dienstag, 7. Mai 13

Page 41: Drupal devdays barcelona 2012 – Staging with git and drush

some drush basics

$ drush pm-downlaod views$ drush pm-enable views $ drush pm-disable devel_themer$ drush pm-update$ drush updatedb$ drush variable_set site_offline 1

Dienstag, 7. Mai 13

Page 42: Drupal devdays barcelona 2012 – Staging with git and drush

and most used

$ drush cache-clear all

Dienstag, 7. Mai 13

Page 43: Drupal devdays barcelona 2012 – Staging with git and drush

drush knows remotes, too!

Dienstag, 7. Mai 13

Page 44: Drupal devdays barcelona 2012 – Staging with git and drush

drush knows remotes, too!

called site-aliases

Dienstag, 7. Mai 13

Page 45: Drupal devdays barcelona 2012 – Staging with git and drush

drush site-aliases

aliases.drushrc.php

Dienstag, 7. Mai 13

Page 46: Drupal devdays barcelona 2012 – Staging with git and drush

drush site-aliases

aliases.drushrc.php

$aliases['integration'] = array( 'uri' => 'integration.server', 'root' => '/var/www/integration.server/docroot', 'remote-host' => 'integration.server', 'remote-user' => 'integration-user');

Dienstag, 7. Mai 13

Page 47: Drupal devdays barcelona 2012 – Staging with git and drush

$ drush @integration status

drush site-aliases

Dienstag, 7. Mai 13

Page 48: Drupal devdays barcelona 2012 – Staging with git and drush

syncing files directory

Dienstag, 7. Mai 13

Page 49: Drupal devdays barcelona 2012 – Staging with git and drush

use drush to sync files

$ drush rsync \\ default:%files @integration:%files

Dienstag, 7. Mai 13

Page 50: Drupal devdays barcelona 2012 – Staging with git and drush

syncing the database

Dienstag, 7. Mai 13

Page 51: Drupal devdays barcelona 2012 – Staging with git and drush

in $aliases['integration']

'databases' => array( 'default' => array( 'default' => array( 'driver' => 'mysql', 'database' => 'integration', 'username' => 'integration', 'password' => 'supersecret', 'host' => 'localhost', 'prefix' => '', 'collation' => 'utf8_general_ci', ), ),),

Dienstag, 7. Mai 13

Page 52: Drupal devdays barcelona 2012 – Staging with git and drush

in $aliases['integration']

'path-aliases' => array( '%dump-dir' => '/home/integration-user/db-dumps',),'command-specific' => array( 'sql-sync' => array ( 'no-cache' => TRUE, 'sanitize' => TRUE, 'structure-tables' => array( 'common' => array('cache', 'cache_menu', '…', 'sessions', 'watchdog'),),

Dienstag, 7. Mai 13

Page 53: Drupal devdays barcelona 2012 – Staging with git and drush

sync your database

$ drush sql-sync \\ default @integration

Dienstag, 7. Mai 13

Page 54: Drupal devdays barcelona 2012 – Staging with git and drush

next problem:

Dienstag, 7. Mai 13

Page 55: Drupal devdays barcelona 2012 – Staging with git and drush

multiple developers

next problem:

Dienstag, 7. Mai 13

Page 56: Drupal devdays barcelona 2012 – Staging with git and drush

no problem

Dienstag, 7. Mai 13

Page 57: Drupal devdays barcelona 2012 – Staging with git and drush

dev A

dev B

integration

index.phpupdate.phpmodules/includes/sites/…

Dienstag, 7. Mai 13

Page 58: Drupal devdays barcelona 2012 – Staging with git and drush

dev A

dev B

integration

index.phpupdate.phpmodules/includes/sites/…

Git is a distributed VCS

Dienstag, 7. Mai 13

Page 59: Drupal devdays barcelona 2012 – Staging with git and drush

summary

Dienstag, 7. Mai 13

Page 60: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

summary

Dienstag, 7. Mai 13

Page 61: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

summary

Dienstag, 7. Mai 13

Page 62: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

summary

Dienstag, 7. Mai 13

Page 63: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

• teamwork

summary

Dienstag, 7. Mai 13

Page 64: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

• teamwork

• deployment to docroot on the server

summary

Dienstag, 7. Mai 13

Page 65: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

• teamwork

• deployment to docroot on the server

• put as much in code as possible

summary

Dienstag, 7. Mai 13

Page 66: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

• teamwork

• deployment to docroot on the server

• put as much in code as possible

• features, strongarm, install profiles, …

summary

Dienstag, 7. Mai 13

Page 67: Drupal devdays barcelona 2012 – Staging with git and drush

• no forgotten files

• much faster uploads

• version history

• teamwork

• deployment to docroot on the server

• put as much in code as possible

• features, strongarm, install profiles, …

• hook_update_N

summary

Dienstag, 7. Mai 13

Page 68: Drupal devdays barcelona 2012 – Staging with git and drush

code staging

a possible workflow

Dienstag, 7. Mai 13

Page 69: Drupal devdays barcelona 2012 – Staging with git and drush

Dienstag, 7. Mai 13

Page 70: Drupal devdays barcelona 2012 – Staging with git and drush

boss

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 71: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 72: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 73: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stagedev

dev

dev

dev

Dienstag, 7. Mai 13

Page 74: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stagedev

dev

dev

dev

Dienstag, 7. Mai 13

Page 75: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stage

live

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 76: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stage

live

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 77: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stage

live

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 78: Drupal devdays barcelona 2012 – Staging with git and drush

boss

integration

stage

live

dev

dev

dev

dev

Dienstag, 7. Mai 13

Page 79: Drupal devdays barcelona 2012 – Staging with git and drush

Links

Git

http://git-scm.comhttp://gitref.org/index.htmlhttp://rogerdudler.github.com/git-guide/http://sitaramc.github.com/gitolite/

Drush

http://drush.orghttp://drupal.org/documentation/modules/drush

Dienstag, 7. Mai 13

Page 80: Drupal devdays barcelona 2012 – Staging with git and drush

Questions!

Dienstag, 7. Mai 13

Page 81: Drupal devdays barcelona 2012 – Staging with git and drush

Thank you!

Dienstag, 7. Mai 13