Managing Drupal sites with git - Part 1
At $WORK we build and manage quite a few Drupal sites.
In an effort to streamline things we are trialling a new workflow when working on Drupal sites.
The goals we wanted to achieve was to have everything in GIT and to have each customers site portable.
By portable I mean that it can easily be moved between our different drupal servers and also between Drupal multisite and dedicated Drupal hosting.
We have GIT repos of all the Drupal modules we use and use GIT submodules to drag these modules in for a site.
Each night a tarball of the sites mysql and sites/example.com/files/ is sent to a central server that serves these out via HTTPS (with AUTH of course).
This makes it very easy for a developer to grab production data to develop with.
Below is an example of our current workflow. This is only a day old and not really been put to a lot of use but in testing it seems to flow ok. Time will tell.
- Setup a Drupal install if you don't have one:
git clone gitosis@gitserver:drupal6.git /var/www/drupal - Clone the site's repository into the sites/ folder:
git clone gitosis@gitserver:example.com.au.git /var/www/drupal/sites/example.com- Change into freshly cloned sites folder
cd /var/www/drupal/sites/example.com - Initialize submodules:
git submodule init - Update submodules:
git submodule update
- Change into freshly cloned sites folder
- Download and install the latest database backup. Take care to remove the contained email addresses.
- Download the latest files folder backup and extract into the site's folder.
- Configure the settings.php file to point to the right database.
- Create an Apache vhost and /etc/hosts entry to point traffic to your local installation
- Make your modifications.
- Commit to your Git repository.
- Push to the main repository if you have write access, otherwise notify someone who does.
Notes
- Everything is kept in the domains site folder(sites/example.com) and nothing goes in sites/all or sites/default
- Sites must be self contained, i.e., they should not make reference to anything from another sites folder, including sites/all.
- All modules must be added as Git submodules.
It's very early days using this new workflow so I am not sure how well it will go but so far it appears to be a big step in the right direction.
Once we have mastered this and converted all our sites over to GIT we will then look to finding a better way to handle sql changes progressing through the dev,test,staging,production lifecycle.
