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

staging with git drush markus heurung muhh markus
SMART_READER_LITE
LIVE PREVIEW

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/


slide-1
SLIDE 1

Staging with git & drush

slide-2
SLIDE 2

freistil IT

Markus Heurung – @muhh markus@freistil.it

slide-3
SLIDE 3

„Deploying“ the old way

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

FTP

work fix

slide-4
SLIDE 4

write-write conflict

multiple developers

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

slide-5
SLIDE 5

SUCKS!

slide-6
SLIDE 6

develop locally!

slide-7
SLIDE 7

XAMPP/MAMP Acquia Dev Desktop Linux Mac OS X

slide-8
SLIDE 8

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

slide-9
SLIDE 9

Version Control

slide-10
SLIDE 10

Git

slide-11
SLIDE 11

Repository

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

put your code into git

slide-12
SLIDE 12

Some git basics

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

slide-13
SLIDE 13

some git basics

$ git add docroot/ $ git commit docroot/

slide-14
SLIDE 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"

slide-15
SLIDE 15

Repository

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

put your code into git

slide-16
SLIDE 16

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

transfer commits

local integration

slide-17
SLIDE 17

git remote repositories

slide-18
SLIDE 18

working with remotes

$ git remote add integration \\ git@integration.server:test.git

slide-19
SLIDE 19

transfer commits

$ git push integration $ git pull integration

slide-20
SLIDE 20

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

transfer commits

local integration

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

pull push

slide-21
SLIDE 21

let the server deploy the code to its docroot

slide-22
SLIDE 22

git knows hooks!

slide-23
SLIDE 23

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

slide-24
SLIDE 24

What about sites/*/files?

slide-25
SLIDE 25

not in git!

slide-26
SLIDE 26

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

let git ignore it

slide-27
SLIDE 27

drush

slide-28
SLIDE 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

slide-29
SLIDE 29

and most used

$ drush cache-clear all

slide-30
SLIDE 30

drush knows remotes, too! called site-aliases

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

slide-32
SLIDE 32

$ drush @integration status

drush site-aliases

slide-33
SLIDE 33

syncing files directory

slide-34
SLIDE 34

use drush to sync files

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

slide-35
SLIDE 35

syncing the database

slide-36
SLIDE 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', ), ), ),

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

slide-38
SLIDE 38

sync your database

$ drush sql-sync \\ default @integration

slide-39
SLIDE 39

multiple developers

next problem:

slide-40
SLIDE 40

no problem

slide-41
SLIDE 41

dev A dev B

integration

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

Git is a distributed VCS

slide-42
SLIDE 42
  • 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

slide-43
SLIDE 43

code staging a possible workflow

slide-44
SLIDE 44

boss

integration

stage

live

dev dev dev dev

slide-45
SLIDE 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

slide-46
SLIDE 46

Questions!

slide-47
SLIDE 47

Thank you!