Building Sites from Common Codebases with Pantheon for Agencies

As you might have heard, we recently launched our game changing Pantheon for Agencies experience which allows all of our partner web development agencies to have a single dashboard to manage all of their Drupal and WordPress sites.

My favorite feature of the Pantheon for Agencies is definitely the ability to allow partner agencies to be able to easily create and update sites from a common codebase. In this post I am going to explain to you why you might want to use such an approach and how you might go about doing that using the technology of Pantheon.

The Why: Use Cases for Common Codebases

While not for every agency or organization, there are a few great reasons for using common codebases for your projects:

  • Getting Started Fast - Instead of beginning each project doing basically the same technical work (installing the same plugins / modules, setting up your base theme / framework, doing basic common configuration) you can start each project with a bunch of the work already done by using a common codebase!

  • Long Term Sustainability - Especially for agencies who are providing long term support for their customers, common codebases make it easy to maintain your sites’ code over the long run. Instead of updating each site on a one by one basis, just make the update once to the common codebase and push it out to all your sites using our site manager dashboard (with proper testing of course).

  • Easy Developer Onboarding - While not necessarily an explicitly technical benefit, we have seen organizations who standardize on a common codebase (and with it a common site architecture) save a lot of time onboarding and training their new developers because they can focus their efforts teaching to that codebase which is available for all to see / test / develop.

In practice, there are a lot of ways that our customers and partner agencies use their common codebases. They include:

  • Fully Baked Drupal Distributions - While definitely the most work to create, partners like LevelTen Interactive with their Open Enterprise distribution and Phase2 with theirOpen Atrium distribution (among others) can easily spin up sites based on a fully baked Drupal install profile. This means they can fully install their sites in minutes and roll out great functionality right out of the box. There is still plenty of customization work to do afterwards, but they start much further down the path and roll back any custom functionality they develop regularly back into the common codebase.

  • Base Distribution + Hot Sauce - For partners like Kalamuna who regularly use public base distributions but want to add their own special hot sauce, they are able to combine their base distribution (Panopoly) with their custom theme (Kalatheme) with a few other special additions and start their projects from there.

  • Lightweight Starting State - For organizations who just want to have some basic functionality out of the box but don’t want to build a full distribution, it is possible to create a lightweight Drupal install profile like Zivtech's Bear which can just turn on common modules and do some lightweight common config for an easy win.

  • Just the Code - If you don’t want to go down the distribution road, you can also just directly add your common modules + themes to the common codebase and then install them manually when you setup each site. You still get all the benefits of easy updatability of the code and installation is still much faster since you already have the code you need right there. For bonus points if you using Drupal, you can even add some of your own features which can do automatic configuration of your site when turned on. 

 

The How: Pantheon One + The Magic of Git Upstreams

On a technical level, Mr. Joshua Koenig has written much about the failings of multisitewhich I won’t rehash here except to say that in today’s world - with it’s modern version control solutions like Git - the idea that you need to run the same code from the same docroot to run multiple sites on the same codebase is just silly. Aside from all the problems that causes related to security, performance, and maintainability, thefunctionality you get from such approach is also limited. You cannot have both a common codebase and the ability to customize that code - which is a pretty common need these days.

Here at Pantheon we believe that you need to give people what they want and that is why, as part of Pantheon One for Agencies, we are providing our users access to the best of both worlds - the ability to have a common codebase and the ability to customize that on a per site basis. Here is how it works:

First, you need to create a Git repository which will be the source for your common code. The easiest way to do this is to just fork our starting upstream repository for either Drupalor WordPress into your own repository. Your repository can live anywhere on the internet you want (including being a private repository on Bitbucket or Github) and you will have complete control to commit any code you like to that repository. So go ahead and fork!

Fork on GitHub

Second, you need to provide us (just open a support ticket or send an email) with the link to the repository and relevant access (if you are using a private repository). This will allow us to connect your product to your Pantheon One account which will give members of your organization access to your codebase. Here is how it will look in your dashboard:

Products in P14A

Third, create sites based on that codebase! When creating new sites on Pantheon, all members of your organization will see a new option to start with your “organizational” distribution as well as normal Drupal or WordPress. If you select the organizational distribution, this will start your new site with the latest and greatest code from your custom Git repository.

Create Site from Product in P14A

Fourth, go install and develop your sites as normal! Since they are all sites on Pantheon with its full magic, they will each have their own Git repository to which you can make any site specific change you want. This will allow you a lot of flexibility, but don’t worry - the site will retain a connection to the original upstream which will be useful later for updating:

Upstream Relationship

Fifth, when you have a need to do an update, you just need to do the commit in one place - to your common repository. Once that commit has been made, you are visibility alerted on each site that an update is available and with a single click you can apply that update to that site. Since this is technically done as a git merge, it isn’t a problem if you have made non-conflicting changes to the codebase. Even if you do have conflicts, we have a nifty option to auto-resolve conflicts in favor of the upstream repository and, of course, allow for manual resolution of git conflicts on the command line (if it comes to that).

Pantheon One for Agencies Code Update

As a bonus, the Pantheon One for Agencies dashboards provides the ability to filter for sites that are running off your custom common codebase. Once filtered, you can also see the “Code Status” for each site to quickly drill down to sites that are up to date or sites that still have updates to apply!

Pantheon One for Agencies Dashboard Filter for Product

If this looks like something you might be interested in, get in touch with us! Pantheon One for Agencies is complimentary to all partners and it's free and pretty easy to become a partner.

Topics Development

Let’s get in touch

855-927-9387