Deployments
On production sites
The deployment strategy used at amazee.io for production is heavily inspired by capistrano.
Filesystem Structure
home directory (like /var/www/site_name)
├── public_html -> /var/www/site_name/releases/20160607095555Z/
├── releases
│ ├── 20160612075028Z
│ ├── 20160607095542Z
│ └── 20160607095555Z
├── repo
│ └── <GIT repo>
└── shared
└── <shared directories>
Folders
public_htmlis a symlink pointing to the latest release. This symlink is updated after thebefore_deploytasks are executed. If the deployment fails before or during execution ofbefore_deploytasks the symlink is not touched and still points to the old release.releasesholds all deployments in a timestamped folder in UTC. These folders are the target of the current symlink. We keep 3 release folders present, the older folders get deleted after a successful deploymentrepoholds a checkout of the configured git repository.sharedcontains directories which are symlinked into each release. This data persists across deployments and releases. It is used for things like the Drupal files directory.
Task execution order
This shows the order of a production deployment. If on a cluster stack, these tasks are all executed simultaneously at the same time on all backends:
- The git repo inside
repois checked out to the desired git branch (basically agit pull) - The whole folder
repois copied into thereleasesfolder, with the folder name of the current time in UTC. The
before_deploytasks are executed inside the created folder.- Important:
before_deploytasks should only be used for tasks that do not change anything on the Drupal Database and for tasks that need to be executed on all servers within a cluster. Some examples:composer install,npm - If any of these
before_deploytasks failed (return code is not 0), the deployment is stopped immediately and the created directory for the failed deployment within thereleasesdirectory is removed.
- Important:
The
public_htmlsymlink is switched to the new folder withinreleases- This is referred to as the actual deploy. (this why the tasks are called
beforeandafterdeploy tasks)
- This is referred to as the actual deploy. (this why the tasks are called
The
after_deploytasks are executed (if on cluster only on one backend!).- Important:
after_deploytasks should be used for tasks that change database related things likedrush updbor for tasks that should be executed only once in a cluster environment, likedrush cr. - If any of the
after_deploytasks failed (return code is not 0), the rollback routine is called on all backends:- The
public_htmlsymlink is changed back to the previous deployment. - The
releasesfolder of the failed deployment is removed. - No tasks from the
before_deployorafter_deploytask lists are executed, as the state of the Drupal site is very hard to understand for the deployment system. In case of a rollbacked deployment, you should ensure yourself that the site is working properly.
- The
- Important:
On development sites
Development sites do not need a complex deployment system and are therefore easier. Basically it's just a git pull directly on the public_html directory and deployment tasks executed.
Filesystem Structure
home directory (like /var/www/site_name)
└── public_html
Folders
public_htmlis a git checkout of the desired git branch
There are no additional directories, everything is within public_html
Task execution order
- The git repository inside
public_htmlis checked out to the desired git branch (basically agit pull) - The
before_deploytasks are executed inside thepublic_htmlfolder.- If any of these
before_deploytasks failed (return code is not 0), the deployment is stopped immediately, no rollback to the previous deployment is happening.
- If any of these
- The
after_deploytasks are executed.- If any of the
after_deploytasks failed (return code is not 0), the deployment is stopped immediately, no rollback to the previous deployment is happening
- If any of the