Deploy Drupal 8 projects using Capistrano 3

Profile picture for user a.berramou
Azz-eddine BERRAMOU 25 April, 2020

Deploying Drupal 8 projects, it required executing a lot of tasks like:

  • Pull code base from repository / branch 
  • Run composer install to download dependencies and contrib modules
  • Backup database
  • Put site offline
  • Import config
  • Update Database
  • Puts site on line
  • Clear cache 

And so on !

So executing those tasks in each fix or code change, it's a hard!

In this article we will see how to automate those tasks using Capistrano 3.

First of all what is Capistrano?

According to 

Capistrano is a remote server automation tool.

It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workflows.

Read more about its definition on What is Capistrano? section.

For Drupal 7 there is this repo  it's well documented and works perfect.

But as you know in Drupal 8 Drush commands are a little bit different from Drupal 7.

For that purpose i have create this repo drupal8cap adapted to Drupal 8.

Follow readme for installation and configuration, and also it's better to read the readme from the Drupal 7 repository first here.


  1. Gems must be installed on your system first. 
  2. Composer, Drush and Git should be installed on your server
  3. Your server should have access to your repository (ssh key should be in your code base hosting Github/Gitlab/Bitbucket ...)

I hope this help you gain a little bit of time and facilitate your deployment process.

If you have any question or you need some help, don't hesitate to let a comment bellow.