Staging with git & drush
Dienstag, 7. Mai 13
freistil IT
Markus Heurung – @muhh
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
work
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
work
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
work
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
workfix
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
workfix
Dienstag, 7. Mai 13
„Deploying“ the old way
index.phpupdate.phpmodules/includes/sites/…
FTP
workfix
Dienstag, 7. Mai 13
multiple developers
index.phpupdate.phpmodules/includes/sites/…
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
multiple developers
index.phpupdate.phpmodules/includes/sites/…
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
multiple developers
index.phpupdate.phpmodules/includes/sites/…
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
write-write conflict
multiple developers
index.phpupdate.phpmodules/includes/sites/…
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
SUCKS!
Dienstag, 7. Mai 13
develop locally!
Dienstag, 7. Mai 13
XAMPP/MAMP
Acquia Dev Desktop
Linux
Mac OS X
Dienstag, 7. Mai 13
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
index.phpupdate.phpmodules/includes/sites/…
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
Version Control
Dienstag, 7. Mai 13
Git
Dienstag, 7. Mai 13
Repository
index.phpupdate.phpmodules/includes/sites/…
put your code into git
Dienstag, 7. Mai 13
Repository
index.phpupdate.phpmodules/includes/sites/…
put your code into git
Dienstag, 7. Mai 13
Some git basics
$ git add $FILE(S)$ git commit $FILE(S)
Dienstag, 7. Mai 13
some git basics
$ git add docroot/$ git commit docroot/
Dienstag, 7. Mai 13
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
Repository
index.phpupdate.phpmodules/includes/sites/…
put your code into git
Dienstag, 7. Mai 13
index.phpupdate.phpmodules/includes/sites/…
transfer commits
local integration
Dienstag, 7. Mai 13
git remote repositories
Dienstag, 7. Mai 13
transfer commits
$ git push integration$ git pull integration
Dienstag, 7. Mai 13
index.phpupdate.phpmodules/includes/sites/…
transfer commits
local integration
pull
push
Dienstag, 7. Mai 13
index.phpupdate.phpmodules/includes/sites/…
transfer commits
local integration
index.phpupdate.phpmodules/includes/sites/…
pull
push
Dienstag, 7. Mai 13
let the serverdeploy the code
to its docroot
Dienstag, 7. Mai 13
git knows hooks!
Dienstag, 7. Mai 13
.git/hooks/post-receive
→ go to docroot and do a git pull
Dienstag, 7. Mai 13
What about sites/*/files?
Dienstag, 7. Mai 13
not in git!
Dienstag, 7. Mai 13
$ echo "sites/*/files" >> .gitignore
let git ignore it
Dienstag, 7. Mai 13
drush
Dienstag, 7. Mai 13
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
and most used
$ drush cache-clear all
Dienstag, 7. Mai 13
drush knows remotes, too!
Dienstag, 7. Mai 13
drush knows remotes, too!
called site-aliases
Dienstag, 7. Mai 13
drush site-aliases
aliases.drushrc.php
Dienstag, 7. Mai 13
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
$ drush @integration status
drush site-aliases
Dienstag, 7. Mai 13
syncing files directory
Dienstag, 7. Mai 13
use drush to sync files
$ drush rsync \\ default:%files @integration:%files
Dienstag, 7. Mai 13
syncing the database
Dienstag, 7. Mai 13
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
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
sync your database
$ drush sql-sync \\ default @integration
Dienstag, 7. Mai 13
next problem:
Dienstag, 7. Mai 13
multiple developers
next problem:
Dienstag, 7. Mai 13
no problem
Dienstag, 7. Mai 13
dev A
dev B
integration
index.phpupdate.phpmodules/includes/sites/…
Dienstag, 7. Mai 13
dev A
dev B
integration
index.phpupdate.phpmodules/includes/sites/…
Git is a distributed VCS
Dienstag, 7. Mai 13
summary
Dienstag, 7. Mai 13
• no forgotten files
summary
Dienstag, 7. Mai 13
• no forgotten files
• much faster uploads
summary
Dienstag, 7. Mai 13
• no forgotten files
• much faster uploads
• version history
summary
Dienstag, 7. Mai 13
• no forgotten files
• much faster uploads
• version history
• teamwork
summary
Dienstag, 7. Mai 13
• no forgotten files
• much faster uploads
• version history
• teamwork
• deployment to docroot on the server
summary
Dienstag, 7. Mai 13
• 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
• 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
• 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
code staging
a possible workflow
Dienstag, 7. Mai 13
Dienstag, 7. Mai 13
boss
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stagedev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stagedev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stage
live
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stage
live
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stage
live
dev
dev
dev
dev
Dienstag, 7. Mai 13
boss
integration
stage
live
dev
dev
dev
dev
Dienstag, 7. Mai 13
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
Questions!
Dienstag, 7. Mai 13
Thank you!
Dienstag, 7. Mai 13