6099 comments
2357 subscribers
6263 on Twitter
Subscribe! Feed reader E-mail

Drupal: Deploying two branches to three systems

To keep track of the bugfixes we’ll need to make for our next release, I’ve created a Subversion branch called branches/release-1. Development of new features will continue on trunk, but we’ll merge in the bugfixes from release-1 every so often.

There are three environments we deploy to:

Local
Developers should be able to easily test both versions on their local machines.
QA server
We should be able to deploy both versions to a publicly-accessible QA server for acceptance testing.
Production server
We should be able to deploy release-1 (and then later, release-2 and so on) to the production server, preferably after a lot of testing

Editorial changes happen on the production server, where our users update content. We would like to be able to take a snapshot of that database and use that to test our development code on the QA server or in our local development environments. Because we use Domain Access to serve multiple subdomains with shared content, it’s not just a matter of using mysqldump to back up the database and copy it over. We also need to replace URLs inside the database, and we need to override domain_root using the $conf array in settings.php.

I’m the only one running Linux, so the other developers don’t really benefit from the Makefiles I’ve defined or the tools I use. For the simpler build system we had before (all development on trunk), I wrote a deployment script that allowed users to:

  • Download a stripped copy of the production database with the URLs changed for their local testing environment
  • Deploy a stripped copy of the production database to the QA server
  • Deploy a specified revision of the source code to the QA server
  • Deploy a specified revision of the source code to the production server

The new deployment script needed to allow users to do the same, but for both branches of the code. Both branches of the code would be simultaneously available on the QA server, so the script would need to deploy the code to different directories.

After some fiddling around with the page design (because I care about making interfaces make sense!), I came up with something that looks like this:

  Development Release-1
Local Database
QA Database
QA Deployment

Production Deployment None

Changelog
-------
r988 | somegeek | 2008-09-15 13:00:00 -0500 (Mon, 15 Sep 2008) | 2 lines

Use dev.qa.example.com
------------
[more changelog entries go here]
------------------------------------------------------------------------
r986 | somegeek | 2008-09-15 11:03:38 -0500 (Mon, 15 Sep 2008) | 3 lines

Starting a branch for release-1
------------------------------------------------------------------------
[more changelog entries go here]

The deployment script allows the user to get a copy of the database, deploy a copy of the database, or deploy specific revisions of branches.

Because I was having a hard time figuring out how to do ssh key-based operations from Apache (which runs as a no-login user), I use two shell scripts to do the dirty work. One shell script connects to the production server, creates a partial backup, copies the information over, and does any necessary replacements. Another shell script takes a domain name and optionally a revision, and deploys the revision from the appropriate branch.

Here’s my totally small-scale PHP way to show the revisions log:

$dev_output = shell_exec("svn log $dev_url $details --limit 20");
$dev_revisions = preg_match_all('/r([0-9]+)/', $dev_output, $dev_matches);

where $dev_url is the URL of the trunk in Subversion, and $details contains the username and password specified as options for the Subversion command-line.

I’m going to see if I can get my regression tests running on the server that I’ve got my deployment script on. Wouldn’t that be awesome?

Short URL: http://sachachua.com/blog/p/5151
  • http://www.danieltome.com Daniel Tome

    Are you willing to share your scripts? I’m interested in knowing how you merge the databases from the different environments.

    Thanks

  • http://sachachua.com Sacha Chua

    We don’t merge databases. We can get away with that because all the configuration changes are in the source code, and we don’t need to stage content changes. =)

On This Day...

  • 2011: Learning new tricks about learning: maps and history — From Tuesday: J- has started Grade 8, the year before high school. Last schoolyear, we invested more time into helping [...]
  • 2010: ‘round the bend — You know those moments in formulaic movies. Our heroes hit their lowest points. Everything looks stressful. Then something changes, and [...]
  • 2009: Quick thoughts — I’m starting to accumulate a backlog of things to write about. Life is too interesting to capture, and yet too [...]
  • 2008: Drupal and Drush: Updating the database from the command-line — So now that we’re doing all our configuration changes in source code, it makes sense to automate database updates as [...]
  • 2008: Working on a small project — Working on a small project means that I wear multiple hats, and that’s helping me grow so much as a [...]
  • 2007: Weekly review — Here are the highlights of the last week: Finally got my paperwork together for the post-graduate work permit! After following up [...]
  • 2007: Attack of the killer tomatoes — Vine-ripened tomatoes were on sale at No Frills, so we bought some 15 pounds of plump, red, juicy, fragrant tomatoes. Mmm! [...]
  • 2006: Wow. Statistics can be fun. — I have a new favorite statistics textbook. Not that I had one before. Who knew that a statistics textbook could [...]
  • 2006: Self-portrait with vintage hat — One of the things that surprises people is that as high-tech and plugged in as I am, I still have an [...]
  • 2006: Twice-baked potatoes — One of the simple joys in life is waking up (relatively) early on a weekend morning and preparing a proper [...]
  • 2006: Networking party in New York that I really, really want to go to — The Greater IBM Initiative is having its first party in New York City on Thursday, Sept 21. I really, really [...]
  • 2005: Silk-screening workshop — Peach Berserk‘s silk-screening workshop looks amazing. I love their dresses, but not their prices! <laugh> Let’s start out by silkscreening something small, and [...]
  • 2005: Geekwear — I actually like wearing geek swag: clothes and accessories with a logo or geek reference. Geek swag identifies me to other [...]
  • 2005: Places to shop — ACT TWO 596 Mount Pleasant, 416-487-2486 Designer cast-offs CHOCKY’S 352 Queen West, 416-977-1831; 2584 Yonge, 416-483-8227 Pajamas and jackets ENDS 1930 Queen East, 416-699-2271, etc. Wool overcoats, etc. JO’S [...]
  • 2003: Linux in Education links — http://pchb1f.gallaudet.edu/tricki/
  • 2003: Plans for CS21A tomorrow — I think we’ll have fun. =) A lecture on searching and sorting - modified slides, whiz through most of it and [...]
  • 2003: CS1 site — - http://www.cs.up.ac.za/javagently/ListEx.html has a lot of examples, and it has an overarching project. Hmm. Stuff seems to come from the Java Gently [...]
  • 2003: Interesting words — - http://phrontistery.50megs.com/ - http://phrontistery.50megs.com/scrabble3.html
  • 2003: Hare Race — That didn’t go too well; not polished enough. The exercise is at HareRace-20030916.jar just in case.
  • 2002: (Mon Sep 16:23 2002, *Messages*) — Fixed planner remember bug – context was getting picked up after the switch of buffer.
  • 2002: (Mon Sep 16:59 2002, 2002.09.16) — Jean Paul Sartre self-making essentialism
  • 2002: (Mon Sep 16:34 2002, 2002.09.16) — http://www.jobstreet.com.ph/career/streetwise/women8.htm
  • 2002: (Mon Sep 16:52 2002, 2002.09.16) — http://www.xref-tech.com/

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!