Skip to main content

Building and maintaining Drupal + CiviCRM application containers

In my previous two posts, I provided some background into why I decided on using containers for a boutique Drupal + CiviCRM hosting platform, and why Docker and its micro-services approach is a good choice for building and maintaining containers.

Although I promised to talk about orchestration, that was getting ahead of the story - first I'm going to look at the challenge of keeping your application containers up-to-date with OS and application-level updates. There's a fair amount of work in that, but the tooling is mature and there is lots of good documentation.

A great place to start is to visit the official Drupal docker hub page. From there, you can pull a working Drupal code container, and it gets re-built frequently with all the OS and Drupal-code updates, so you just refresh your containers whenever you want (i.e. whenever a security release comes out, or more often to stay up-to-date).

A nice thing about that project is that it demonstrates a technique for maintaining multiple Drupal versions over time, with multiple variants of each one for apache with mod_php, nginx with php-fpm, and even a variant using an alpine base image. To see how that works, visit the github docker-library drupal project, which is used to automatically generate the images on docker hub.

My first working attempt at a Drupal + CiviCRM container was loosely based on the project code at the time - I copied over the Drupal 7-apache Dockerfile and modified it with some additional requirements for CiviCRM. That attempt has evolved somewhat, but is still the basis for my production containers.

But since it's grown to include a fair amount of customization specific to my needs, and since the Drupal project code has evolved somewhat, I've re-created the idea as an "open-source" kind of Drupal + CiviCRM application container.

The way I've implemented the CiviCRM support adds some additional complexity. I want to continue to get updates from origin project, so my project's master branch just pulls from the Drupal origin project, and then I've added two new permanent custom branches. Updates from master branch can then get merged up to these two new custom branches. The first branch "civicrm-5" adds the required OS bits to host a Drupal 7/CiviCRM 5 install, i.e. things like imagemagick and SOAP. The second branch "civicrm-5-stable" also adds the civicrm code base itself. Both images are useful in different contexts. Each branch with each Drupal variant can then be used to generate a docker image, and I've set those up on docker hub, where you'll see quite a few auto-generated docker images here

https://hub.docker.com/r/blackflysolutions/drupal/tags

The convention I've used is to name the tags after the combined drupal variant - civicrm branch that generated the image. I plan to also add some additional bits to the tag to track each different drupal/civi release that they're using.

Note that I (still) haven't actually said anything about orchestration - the process of launching the container in combination with an appropriate sql container and a way to keep the files around when you replace the container with a newer one.

Docker is not for the dilettante.

Popular posts from this blog

IATS and CiviCRM

Update, Nov 2009: I've just discovered and fixed a bug I introduced in the 2.2 branch for the IATS plugin. The bug was introduced when i updated the API files from IATS and failed to notice that the legacy method for C$ one-time donations was no longer supported.
If you're using a version greater than or equal to 2.2.7, and are using IATS for C$, non-recurring donations, then you're affected.
To fix it edit the file : CRM/Core/Payment/IATS.php, and remove the line that looks like this:

$canDollar = ($params['currencyID'] == 'CAD'); //define currency type The full fix removes a conditional branch based on that value a little further on, but by removing this line, it'll never actually use that branch. Drop me a line if you have any questions.
Update, May 2009: This post is still getting quite a bit of traffic, which is great. Here are a few important things to note:
The IATS plugin code is in CiviCRM, you don't need to add any code.You do still …

The Tyee: Bricolage and Drupal Integration

The Tyee is a site I've been involved with since 2006 when I wrote the first, 4.7 version of a Drupal module to integrate Drupal content into a static site that was being generated from bricolage. About a year ago, I met with Dawn Buie and Phillip Smith and we mapped out a number of ways to improve the Drupal integration on the site, including upgrading the Drupal to version 5 from 4.7. Various parts of that grand plan have been slowly incorporated into the site, but as of next week, there'll be a big leap forward that coincides with a new design [implemented in Bricolage by David Wheeler who wrote and maintains Bricolage] as well as a new Drupal release of the Bricolage integration module.PlansApplication integration is tricky, and my first time round had quite a few issues. Here's a list of the improvements in the latest version:File space separation. Before, Drupal was installed in the apache document root, which is where bricolage was publishing it's content. This …

Orchestrating Drupal + CiviCRM containers into a working site: describing the challenge

In my previous posts, I've provided my rationale for making use of Docker and the microservices model for a boutique-sized Drupal + CiviCRM hosting service. I've also described how to build and maintain images that could be used for the web server (micro) service part of such a service.

The other essential microservice for a Drupal + CiviCRM website is a database, and fortunately, that's reasonably standard. Here's a project that minimally tweaks the canonical Mariadb container by adding some small configuration bits: https://github.com/BlackflySolutions/mariadb

That leaves us now with the problem of "orchestration", i.e. how would you launch a collection of such containers that would serve a bunch of Drupal + CiviCRM sites. More interestingly, can we serve them in the real world, over time, in a way that is sustainable? i.e. handle code updates, OS updates, backups, monitoring, etc? Not to mention the various crons that need to run, and how about things like…