staging with git drush markus heurung muhh markus

Staging with git & drush Markus Heurung @muhh - PowerPoint PPT Presentation

Staging with git & drush Markus Heurung @muhh markus@freistil.it freistil IT Deploying the old way FTP index.php work update.php modules/ fix includes/ sites/ multiple developers index.php update.php modules/


  1. Staging with git & drush

  2. Markus Heurung – @muhh markus@freistil.it freistil IT

  3. „Deploying“ the old way FTP index.php work update.php modules/ fix includes/ sites/ …

  4. multiple developers index.php update.php modules/ includes/ sites/ … index.php update.php modules/ write-write conflict includes/ sites/ …

  5. SUCKS!

  6. develop locally!

  7. XAMPP/MAMP Acquia Dev Desktop Linux Mac OS X

  8. index.php index.php update.php update.php modules/ modules/ includes/ includes/ sites/ sites/ … …

  9. Version Control

  10. Git

  11. put your code into git index.php update.php modules/ Repository includes/ sites/ …

  12. Some git basics $ git add $FILE(S) $ git commit $FILE(S)

  13. some git basics $ git add docroot/ $ git commit docroot/

  14. 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"

  15. put your code into git index.php update.php modules/ Repository includes/ sites/ …

  16. transfer commits index.php update.php modules/ includes/ sites/ … integration local

  17. git remote repositories

  18. working with remotes $ git remote add integration \\ git@integration.server:test.git

  19. transfer commits $ git push integration $ git pull integration

  20. transfer commits index.php update.php modules/ includes/ sites/ … pull index.php update.php modules/ integration local includes/ sites/ push …

  21. let the server deploy the code to its docroot

  22. git knows hooks!

  23. .git/hooks/post-receive → go to docroot and do a git pull

  24. What about sites/*/files?

  25. not in git!

  26. let git ignore it $ echo "sites/*/files" >> .gitignore

  27. drush

  28. 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

  29. and most used $ drush cache-clear all

  30. drush knows remotes, too! called site-aliases

  31. 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' );

  32. drush site-aliases $ drush @integration status

  33. syncing files directory

  34. use drush to sync files $ drush rsync \\ default:%files @integration:%files

  35. syncing the database

  36. in $aliases['integration'] 'databases' => array( 'default' => array( 'default' => array( 'driver' => 'mysql', 'database' => 'integration', 'username' => 'integration', 'password' => 'supersecret', 'host' => 'localhost', 'prefix' => '', 'collation' => 'utf8_general_ci', ), ), ),

  37. 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'), ),

  38. sync your database $ drush sql-sync \\ default @integration

  39. next problem: multiple developers

  40. no problem

  41. dev A Git is a distributed VCS index.php update.php modules/ integration includes/ sites/ … dev B

  42. summary • 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

  43. code staging a possible workflow

  44. dev dev stage integration dev dev boss live

  45. Links Git http://git-scm.com http://gitref.org/index.html http://rogerdudler.github.com/git-guide/ http://sitaramc.github.com/gitolite/ Drush http://drush.org http://drupal.org/documentation/modules/ drush

  46. Questions!

  47. Thank you!

Recommend


More recommend