DEPLOYER
DEPLOYER.ORG - DEPLOYMENT TOOL FOR PHP
HERNÂNI BORGES DE FREITAS
PHPLX NOVEMBER 2017
ME
-  Long time PHP user ~ early 2000
-  Drupal Expert / Former Acquia
-  Freelance Architect and Developer
-  Addicted to good hobbies – SerBenfiquista.com
Hernani.pt / twitter: hernanibf
DEPLOYMENT
1.  Build release artifact
2.  Identify to which environment you want to deploy (dev,
staging , prod).
3.  Ideally you save a backup of previous application state in
that environment so you can rollback.
4.  Copy artifact to servers
5.  Execute upgrade procedures (clear cache, update
database schemas, configure services, send
notifications ).
6.  Application live
“Software deployment is all of the activities that make a software system
available for use.”
PROBLEMS
•  Deployments/releases can take 10% of overall project time
•  Downtime involved
•  Not automatized? Human errors ready to happen
•  Hard to rollback in failures
•  Complexity increase with number of web nodes,
environments and their difference
WHAT’S TYPICAL
•  Copy code to servers
•  (FTP, RSYNC, etc..)
•  Deploy from source control
•  Git pull, svn checkout
•  Deploying using other tools / platforms
•  Capistrano, Envoyer/Forge, platform tools..
PERFECT WORLD
•  Code is controlled in
a repository
•  Code is deployed
directly from a
branch or tag.
•  Deployment is done
AUTOMATICALLY to
any environment
from a central
location
•  No human errors,
easy to rollback,
minimum deployment
time and downtime.
MEET DEPLOYER
-  PHP package that allows the configuration and execution
of deployments (deployer.org). Started in 2013 by Anton
Medvedev.
-  All deployment configuration defined as a recipe in a
single file (deploy.php)
-  Define Git origin repository
-  Define environments and their hosts
-  Define deployer strategy
-  Define tasks to be executed in different deployment stages
-  Atomic deployment
-  All tasks related with deployment in a single atomic step
-  Maintains consistency across all servers
-  Rollback possible
GOOD FRIENDSHIPS
INSTALLATION
Or with composer
SIMPLE CONFIGURATION
<?php
namespace Deployer;
require' recipe/drupal8.php' ;
set(' repository' ,' git@bitbucket.org:yourorg/yourepo.git' );
host(' web1.example.com' )
->stage(' production' )
->set(' deploy_path' ,' /home/user/site_prod' );
host(' web2.example.com' )
->stage(' production' )
->set(' deploy_path' ,' /home/user/site_prod' );
host(' web3.example.com' )
->stage(' development' )
->set(' deploy_path' ,' /home/user/site_dev' );
Deploy.php
OTHER FEATURES
-  Shared folders
set('shared_dirs', [
'docroot/sites/{{drupal_site}}/files',
'docroot/forum/attachments',
'docroot/forum/avatars',
'docroot/forum/avatars_custom',
]);
-  Writable dirs
set(' writable_dirs' , [ ' docroot/sites/{{drupal_site}}/files’]);
-  Shared files
TYPICAL RECIPE
task(' deploy' , [
' deploy:prepare' ,
' deploy:lock' ,
' deploy:release' ,
' deploy:update_code' ,
' deploy:shared' ,
' deploy:symlink' ,
' deploy:unlock' ,
' cleanup' 
]);
EXECUTION
$ php dep deploy production --branch=master
-  Code is copied to this structure
-  Permissions are set correctly, shared folders are setup
-  Symlink is defined correctly after code is deployed on all servers
-  Update functions are run if defined
-  https://deployer.org/docs/flow
MISC
-  Different strategies to build/deploy:
-  Deployer checking out code on all servers from git
repository
-  Deployer builiding the artifact on a build server and
syncing to all hosts
-  Parallellism
-  Recipes in
https://github.com/deployphp/deployer/tree/master/recipe
-  Custom tasks definition to define in your recipe
task(' build' ,'
composer install
npm install
npm run build
...
');
-  Largest European event for Drupal developers
-  Lisbon - https://lisbon2018.drupaldays.org/
-  July 2nd – July 6th - Iscte
-  Full week of Drupal and open source talks and sprints! Tickets coming soon .
DRUPAL DEV DAYS 2018
Or share your alternative or experience?
Or walk straight to dinner?
QUESTIONS?

Deployer - Deployment tool for PHP

  • 1.
    DEPLOYER DEPLOYER.ORG - DEPLOYMENTTOOL FOR PHP HERNÂNI BORGES DE FREITAS PHPLX NOVEMBER 2017
  • 2.
    ME -  Long timePHP user ~ early 2000 -  Drupal Expert / Former Acquia -  Freelance Architect and Developer -  Addicted to good hobbies – SerBenfiquista.com Hernani.pt / twitter: hernanibf
  • 3.
    DEPLOYMENT 1.  Build releaseartifact 2.  Identify to which environment you want to deploy (dev, staging , prod). 3.  Ideally you save a backup of previous application state in that environment so you can rollback. 4.  Copy artifact to servers 5.  Execute upgrade procedures (clear cache, update database schemas, configure services, send notifications ). 6.  Application live “Software deployment is all of the activities that make a software system available for use.”
  • 5.
    PROBLEMS •  Deployments/releases cantake 10% of overall project time •  Downtime involved •  Not automatized? Human errors ready to happen •  Hard to rollback in failures •  Complexity increase with number of web nodes, environments and their difference
  • 6.
    WHAT’S TYPICAL •  Copycode to servers •  (FTP, RSYNC, etc..) •  Deploy from source control •  Git pull, svn checkout •  Deploying using other tools / platforms •  Capistrano, Envoyer/Forge, platform tools..
  • 7.
    PERFECT WORLD •  Codeis controlled in a repository •  Code is deployed directly from a branch or tag. •  Deployment is done AUTOMATICALLY to any environment from a central location •  No human errors, easy to rollback, minimum deployment time and downtime.
  • 8.
    MEET DEPLOYER -  PHPpackage that allows the configuration and execution of deployments (deployer.org). Started in 2013 by Anton Medvedev. -  All deployment configuration defined as a recipe in a single file (deploy.php) -  Define Git origin repository -  Define environments and their hosts -  Define deployer strategy -  Define tasks to be executed in different deployment stages -  Atomic deployment -  All tasks related with deployment in a single atomic step -  Maintains consistency across all servers -  Rollback possible
  • 9.
  • 10.
  • 11.
    SIMPLE CONFIGURATION <?php namespace Deployer; require'recipe/drupal8.php' ; set(' repository' ,' git@bitbucket.org:yourorg/yourepo.git' ); host(' web1.example.com' ) ->stage(' production' ) ->set(' deploy_path' ,' /home/user/site_prod' ); host(' web2.example.com' ) ->stage(' production' ) ->set(' deploy_path' ,' /home/user/site_prod' ); host(' web3.example.com' ) ->stage(' development' ) ->set(' deploy_path' ,' /home/user/site_dev' ); Deploy.php
  • 12.
    OTHER FEATURES -  Sharedfolders set('shared_dirs', [ 'docroot/sites/{{drupal_site}}/files', 'docroot/forum/attachments', 'docroot/forum/avatars', 'docroot/forum/avatars_custom', ]); -  Writable dirs set(' writable_dirs' , [ ' docroot/sites/{{drupal_site}}/files’]); -  Shared files
  • 13.
    TYPICAL RECIPE task(' deploy', [ ' deploy:prepare' , ' deploy:lock' , ' deploy:release' , ' deploy:update_code' , ' deploy:shared' , ' deploy:symlink' , ' deploy:unlock' , ' cleanup' ]);
  • 14.
    EXECUTION $ php depdeploy production --branch=master -  Code is copied to this structure -  Permissions are set correctly, shared folders are setup -  Symlink is defined correctly after code is deployed on all servers -  Update functions are run if defined -  https://deployer.org/docs/flow
  • 15.
    MISC -  Different strategiesto build/deploy: -  Deployer checking out code on all servers from git repository -  Deployer builiding the artifact on a build server and syncing to all hosts -  Parallellism -  Recipes in https://github.com/deployphp/deployer/tree/master/recipe -  Custom tasks definition to define in your recipe task(' build' ,' composer install npm install npm run build ... ');
  • 16.
    -  Largest Europeanevent for Drupal developers -  Lisbon - https://lisbon2018.drupaldays.org/ -  July 2nd – July 6th - Iscte -  Full week of Drupal and open source talks and sprints! Tickets coming soon . DRUPAL DEV DAYS 2018
  • 17.
    Or share youralternative or experience? Or walk straight to dinner? QUESTIONS?