Overview of development sites with an example deployment workflow for site building.
When working on a Drupal site it is good practice to use one or more separate environments to develop and test your site without impacting the live site's availability to the world. Changes made to the code or configuration of your development site are then deployed via an automated (or manual) process in order to make them available on the live site. This allows you to, for example, create a new content type or change the configuration of your front page view in isolation so that you can preview the changes. You can then deploy those changes without having to resort to manually replicating the changes on the live site.
Drupal developers use a variety of different tools and Drupal APIs to facilitate the synchronization of code and configuration between environments. The complete process is known as a deployment workflow. At a very high level this includes the following steps:
- Make a change to configuration, or code, on a development environment
- Export any configuration changes to a file(s) that can be stored in version control
- Commit code and configuration changes to version control
- Synchronize version-controlled files to the live server
- Run database updates (update.php) and import any configuration changes
- Clear the cache
To improve the process further, figure out how to automate as much of that as possible using tools like Drush, Git, and continuous integration software. The goal is to create a repeatable, reliable process that reduces the time it takes, decreases downtime for your site, and minimize human error.
Drupal currently supports the deployment of code and configuration, but not user-generated content. For more on the difference between the two, see Configuration Data Types.
Workspaces module is a Core (Experimental) module (roadmap) that improves content workflow, preview, and staging abilities. Learn more in the original Workflow Initiative core idea issue.
- Build a new View on your development environment and then deploy it to the production site
- Test and configure a new module locally and then update the production site when ready
- Make changes to your theme or module locally and deploy those changes to the live site
Deployment, and specifically what tools to use and how to use them, continues to evolve. The recommendation of using a development > staging > live workflow whenever possible isn't likely to change. The specifics of these workflows can vary, depending on your hosting provider and other factors. It's best to get a general understanding of the desired workflow and then work with your team to define the specifics for your application and available tools. Resources labeled for Drupal 8 should apply to Drupal 9.
- Workspaces core (experimental) module roadmap (Drupal.org)
- The roadmap of tasks to complete before Workspaces can become a stable core module.
- Continuous Deployment, Infrastructure as Code, and Drupal (article series) (lullabot.com)
- Juampy NR dives into the DevOps world and explores continuous deployment and infrastructure as code in a Drupal project in this multi-part series of articles.
- A Development Workflow for Drupal 8 Projects (lullabot.com)
- Describes a suggested deployment workflow template for new and existing Drupal 8 projects.
- Avoid DEEP HURTING! Deployment beyond git (DrupalCon Baltimore 2017, YouTube)
- Suggests a solid deployment workflow for Drupal sites. This one is based on Ansible, but the concepts and ideas covered are relevant no matter what tools you're using.
- Predictable Continuous Deployment: Value, Culture & Tools (DrupalCon Baltimore 2017, YouTube)
- A good overview of the value of creating a deployment workflow and the various moving parts involved. Covers things involved in a deployment without prescribing specific tools.
- The Ten Commandments of a New Drupal 8 Site for Enterprise Developers (Lullabot.com)
- Ten suggestions on how to get started developing a new Drupal 8 site, most of them deployment related. Worth reading once to make sure you're thinking about all of these things.
- A Successful One-Click Deployment in Drupal 8 (Lullabot.com)
- In this article, we will walk through how to implement, test, and deploy a release of DrupalCamp Spain's website, including some issues we ran into and how we resolved them.