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

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 . Plans Application 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 co...

A Strange Passion for Security

I'm not a computer security expert, but it's been part of my work for many years, in different forms.  A very long time ago, a friend hired me to write up a primer for internet security, and ever since then it's been a theme that's sat in the background and pops up every now and then . But lately, it's started to feel like more than a theme, and but indeed a passion. You may consider computer and internet security to be a dry subject, or maybe you imagine feelings of smugness or righteousness, but "passion" is the right word for what I'm feeling. Here's google's definition: Passion: 1. a strong and barely controllable emotion. 2. the suffering and death of Jesus. Okay, let's just go with number 1. for now. If you followed my link above to other posts about security, you'll notice one from eight years ago where I mused on the possibility of the discovery of a flaw in how https works. Weirdly enough, a flaw in https was discovered shortly...

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