SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
DEPLOYING DRUPAL USING CAPISTRANO
Jochen Verdeyen
@jochenverdeyen
SITUATIONS
PREREQUISITES
SSH
Ruby (local)
Git (servers)
INSTALLATION
Bundler - Gemfile
source 'https://rubygems.org'
group :deploy do
gem 'capistrano', '~> 3.4.0'
end
bundle install
Default setup
bundle exec cap install
├── Capfile
├── config
│ ├── deploy
│ │ ├── production.rb
│ │ └── staging.rb
│ └── deploy.rb
└── lib
└── capistrano
└── tasks
Custom setup
bundle exec cap install STAGES=tst,stag,prd
├── Capfile
├── config
│ ├── deploy
│ │ ├── prd.rb
│ │ ├── stag.rb
│ │ └── tst.rb
│ └── deploy.rb
└── lib
└── capistrano
└── tasks
CONFIGURATION
Capfile
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
deploy.rb
set :application, 'my_app'
set :repo_url, 'git@my-repo.url'
# Branch to deploy
set :branch, 'master'
# Destination path of the application
set :deploy_to, '/var/www/my_app'
# Amount of releases to keep
set :keep_releases, 5
# Default value for linked_files is []
set :linked_files, []
# Default value for linked_dirs is []
set :linked_dirs, []
deploy/tst.rb
# Server
# ======
server 'xxx.xxx.xxx.xxx', roles: %w{app db}, user: 'deploy_user'
DEPLOYING
Deploy flow
bundle exec cap prd deploy
deploy:starting - start a deployment
deploy:started - started hook
deploy:updating - update server(s) with a new release
deploy:updated - updated hook
deploy:publishing - publish the new release
deploy:published - published hook
deploy:finishing - finish the deployment, clean up
deploy:finished - finished hook
Deploy flow - Structure
├── current -> /var/www/my_app/releases/20151106114500/ ──
├── releases │
│ ├── 20151103072500 │
│ ├── 20151104083000 │
│ ├── 20151105093500 │
│ ├── 20151106104000 │
│ └── 20151106114500 ───────────────────────────────────
├── repo
│ └── [VCS related data]
├── revisions.log
└── shared
└── [linked_files and linked_dirs]
Rollback flow
bundle exec cap prd deploy:rollback
deploy:starting
deploy:started
deploy:reverting - revert server(s) to previous release
deploy:reverted - reverted hook
deploy:publishing
deploy:published
deploy:finishing_rollback - finish the rollback, clean up
deploy:finished
Rollback flow - Structure
├── current -> /var/www/my_app/releases/20151106104000/ ──
├── releases │
│ ├── 20151103072500 │
│ ├── 20151104083000 │
│ ├── 20151105093500 │
│ ├── 20151106104000 ───────────────────────────────────
│ └── 20151106114500
├── repo
│ └── [VCS related data]
├── revisions.log
└── shared
└── [linked_files and linked_dirs]
DRUPAL 8
Prerequisites
Drush
Composer
Capfile
# Composer to install drush on the server
require 'capistrano/composer'
deploy.rb
set :application, 'my_app'
set :repo_url, 'git@my-repo.url'
# Branch to deploy
set :branch, 'master'
# Destination path of the application
set :deploy_to, '/var/www/my_app'
# Link files directory
set :linked_dirs, fetch(:linked_dirs, []).push(
"#{fetch(:app_path)}/sites/default/files"
)
deploy/tst.rb
# Server
# ======
server 'xxx.xxx.xxx.xxx', roles: %w{app db}, user: 'deploy_user'
# Map composer and drush commands
# ===============================
SSHKit.config.command_map[:composer] =
"#{shared_path.join("composer.phar")}"
SSHKit.config.command_map[:drush] =
"#{shared_path.join("vendor/bin/drush")}"
Drupal specific tasks
desc 'Create a database backup'
task :backup_db do
on roles(:app) do
within current_path.join(fetch(:app_path)).join('sites/default') do
execute :drush, "sql-dump --result-file=#{current_path}/backup_db.sql"
end
end
end
desc 'Set the site offline'
task :site_offline do
on roles(:app) do
within release_path.join(fetch(:app_path)).join('sites/default') do
execute :drush, "state-set system.maintenance_mode 1 -y"
end
end
end
Drupal specific tasks
desc 'Import configuration from the config directory'
task :config_import do
on roles(:app) do
within release_path.join(fetch(:app_path)).join('sites/default') do
execute :drush, "config-import -y"
end
end
end
desc 'Clear all caches'
task :cache_clear do
on roles(:app) do
within release_path.join(fetch(:app_path)).join('sites/default') do
execute :drush, "cache-rebuild all"
end
end
end
Deploy flow
bundle exec cap prd deploy:drupal
before "deploy:starting", "drupal:backup_db"
deploy:starting - start a deployment
deploy:started - started hook
deploy:updating - update server(s) with a new release
deploy:updated - updated hook
after "drupal:updated", "drupal:site_offline"
after "drupal:site_offline", "drupal:update_db"
after "drupal:update_db", "drupal:config_import"
after "drupal:config_import", "drupal:cache_clear:all"
before "deploy:publishing", "drupal:site_online"
deploy:publishing - publish the new release
deploy:published - published hook
deploy:finishing - finish the deployment, clean up
deploy:finished - finished hook
JENKINS
${WORKSPACE}/deploy/deploy.sh -w ${WORKSPACE} -e tst
deploy.sh
# Go to the Capistrano folder in the workspace
cd ${WORKSPACE}/deploy/capistrano
# Prepare bundle
bundle
bundle install
# Capistrano preparation
bundle exec cap ${ENVIRONMENT} composer:install_executable
bundle exec cap ${ENVIRONMENT} drush:install
# Capistrano deploy
bundle exec cap ${ENVIRONMENT} deploy:drupal
exit 0
DEMO

Contenu connexe

Tendances

Automate All the Things with Grunt
Automate All the Things with GruntAutomate All the Things with Grunt
Automate All the Things with GruntSheelah Brennan
 
NLIT 2011: Chef & Capistrano
NLIT 2011: Chef & CapistranoNLIT 2011: Chef & Capistrano
NLIT 2011: Chef & Capistranonickblah
 
"13 ways to run web applications on the Internet" Andrii Shumada
"13 ways to run web applications on the Internet" Andrii Shumada"13 ways to run web applications on the Internet" Andrii Shumada
"13 ways to run web applications on the Internet" Andrii ShumadaFwdays
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for DevelopersAntons Kranga
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webminpostrational
 
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...NETWAYS
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinarjguerrero999
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development SystemPaul Bearne
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized DevelopmentAdam Culp
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Gavin Pickin
 
JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具謝 宗穎
 
Web Applications with Eclipse RT and Docker in the Cloud
Web Applications with Eclipse RT and Docker in the CloudWeb Applications with Eclipse RT and Docker in the Cloud
Web Applications with Eclipse RT and Docker in the CloudMarkus Knauer
 
Láďa Prskavec: Docker.io
Láďa Prskavec: Docker.ioLáďa Prskavec: Docker.io
Láďa Prskavec: Docker.ioDevelcz
 
MyCPAN (Frozen Perl 2008 Lightning Talk)
MyCPAN (Frozen Perl 2008 Lightning Talk)MyCPAN (Frozen Perl 2008 Lightning Talk)
MyCPAN (Frozen Perl 2008 Lightning Talk)brian d foy
 
Using the Command Line: Bash and WP-CLI
Using the Command Line: Bash and WP-CLIUsing the Command Line: Bash and WP-CLI
Using the Command Line: Bash and WP-CLIMarc Gratch
 
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With ContainersHanoi MagentoMeetup
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazelNatan Silnitsky
 

Tendances (20)

Automate All the Things with Grunt
Automate All the Things with GruntAutomate All the Things with Grunt
Automate All the Things with Grunt
 
NLIT 2011: Chef & Capistrano
NLIT 2011: Chef & CapistranoNLIT 2011: Chef & Capistrano
NLIT 2011: Chef & Capistrano
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
 
"13 ways to run web applications on the Internet" Andrii Shumada
"13 ways to run web applications on the Internet" Andrii Shumada"13 ways to run web applications on the Internet" Andrii Shumada
"13 ways to run web applications on the Internet" Andrii Shumada
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
 
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinar
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
 
JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具JCConf 2015 workshop 動手玩 Java 專案建置工具
JCConf 2015 workshop 動手玩 Java 專案建置工具
 
Web Applications with Eclipse RT and Docker in the Cloud
Web Applications with Eclipse RT and Docker in the CloudWeb Applications with Eclipse RT and Docker in the Cloud
Web Applications with Eclipse RT and Docker in the Cloud
 
Front-end tools
Front-end toolsFront-end tools
Front-end tools
 
Docker.io
Docker.ioDocker.io
Docker.io
 
Láďa Prskavec: Docker.io
Láďa Prskavec: Docker.ioLáďa Prskavec: Docker.io
Láďa Prskavec: Docker.io
 
MyCPAN (Frozen Perl 2008 Lightning Talk)
MyCPAN (Frozen Perl 2008 Lightning Talk)MyCPAN (Frozen Perl 2008 Lightning Talk)
MyCPAN (Frozen Perl 2008 Lightning Talk)
 
Using the Command Line: Bash and WP-CLI
Using the Command Line: Bash and WP-CLIUsing the Command Line: Bash and WP-CLI
Using the Command Line: Bash and WP-CLI
 
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazel
 

En vedette

6928335 eco-umberto-tratado-de-semiotica-general-01
6928335 eco-umberto-tratado-de-semiotica-general-016928335 eco-umberto-tratado-de-semiotica-general-01
6928335 eco-umberto-tratado-de-semiotica-general-01Luis Gonzalez
 
Introducción a Tag Manager
Introducción a Tag ManagerIntroducción a Tag Manager
Introducción a Tag ManagerBiko
 
Innovatie is een vak
Innovatie is een vakInnovatie is een vak
Innovatie is een vakPerformit
 
Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)Ivan Rosolen
 
Aplicando técnicas de UX na reformulação de produtos.
Aplicando técnicas de UX na reformulação de produtos.Aplicando técnicas de UX na reformulação de produtos.
Aplicando técnicas de UX na reformulação de produtos.Ana Cristine Veneziani
 
Manchester United Scouting Report (2015/2016)
Manchester United Scouting Report  (2015/2016)Manchester United Scouting Report  (2015/2016)
Manchester United Scouting Report (2015/2016)Jose Silva Caparros
 

En vedette (7)

6928335 eco-umberto-tratado-de-semiotica-general-01
6928335 eco-umberto-tratado-de-semiotica-general-016928335 eco-umberto-tratado-de-semiotica-general-01
6928335 eco-umberto-tratado-de-semiotica-general-01
 
Introducción a Tag Manager
Introducción a Tag ManagerIntroducción a Tag Manager
Introducción a Tag Manager
 
Innovatie is een vak
Innovatie is een vakInnovatie is een vak
Innovatie is een vak
 
Zurag tosol i-lekts-7
Zurag tosol i-lekts-7Zurag tosol i-lekts-7
Zurag tosol i-lekts-7
 
Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)
 
Aplicando técnicas de UX na reformulação de produtos.
Aplicando técnicas de UX na reformulação de produtos.Aplicando técnicas de UX na reformulação de produtos.
Aplicando técnicas de UX na reformulação de produtos.
 
Manchester United Scouting Report (2015/2016)
Manchester United Scouting Report  (2015/2016)Manchester United Scouting Report  (2015/2016)
Manchester United Scouting Report (2015/2016)
 

Similaire à Deploying Drupal using Capistrano

Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient waySylvain Rayé
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with CapistranoRamazan K
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoAlmir Mendes
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_trainingvideos
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库maclean liu
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
How to install squid proxy on server or how to install squid proxy on centos o
How to install squid proxy on server  or how to install squid proxy on centos oHow to install squid proxy on server  or how to install squid proxy on centos o
How to install squid proxy on server or how to install squid proxy on centos oProxiesforrent
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with dockerJohan Janssen
 
An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring Abhishek Kumar
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabricandymccurdy
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation ProcessVino Harikrishnan
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabSoftware Guru
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf Conference
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPDana Luther
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions Chanaka Lasantha
 
Painless Deployment with Capistrano
Painless Deployment with CapistranoPainless Deployment with Capistrano
Painless Deployment with CapistranoNick Kugaevsky
 

Similaire à Deploying Drupal using Capistrano (20)

Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
How to install squid proxy on server or how to install squid proxy on centos o
How to install squid proxy on server  or how to install squid proxy on centos oHow to install squid proxy on server  or how to install squid proxy on centos o
How to install squid proxy on server or how to install squid proxy on centos o
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring An Express Guide ~ Zabbix for IT Monitoring
An Express Guide ~ Zabbix for IT Monitoring
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions
 
Painless Deployment with Capistrano
Painless Deployment with CapistranoPainless Deployment with Capistrano
Painless Deployment with Capistrano
 

Dernier

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Dernier (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Deploying Drupal using Capistrano

  • 1. DEPLOYING DRUPAL USING CAPISTRANO Jochen Verdeyen @jochenverdeyen
  • 3.
  • 4.
  • 5.
  • 8. Bundler - Gemfile source 'https://rubygems.org' group :deploy do gem 'capistrano', '~> 3.4.0' end bundle install
  • 9. Default setup bundle exec cap install ├── Capfile ├── config │ ├── deploy │ │ ├── production.rb │ │ └── staging.rb │ └── deploy.rb └── lib └── capistrano └── tasks
  • 10. Custom setup bundle exec cap install STAGES=tst,stag,prd ├── Capfile ├── config │ ├── deploy │ │ ├── prd.rb │ │ ├── stag.rb │ │ └── tst.rb │ └── deploy.rb └── lib └── capistrano └── tasks
  • 12. Capfile # Load DSL and set up stages require 'capistrano/setup' # Include default deployment tasks require 'capistrano/deploy'
  • 13. deploy.rb set :application, 'my_app' set :repo_url, 'git@my-repo.url' # Branch to deploy set :branch, 'master' # Destination path of the application set :deploy_to, '/var/www/my_app' # Amount of releases to keep set :keep_releases, 5 # Default value for linked_files is [] set :linked_files, [] # Default value for linked_dirs is [] set :linked_dirs, []
  • 14. deploy/tst.rb # Server # ====== server 'xxx.xxx.xxx.xxx', roles: %w{app db}, user: 'deploy_user'
  • 16. Deploy flow bundle exec cap prd deploy deploy:starting - start a deployment deploy:started - started hook deploy:updating - update server(s) with a new release deploy:updated - updated hook deploy:publishing - publish the new release deploy:published - published hook deploy:finishing - finish the deployment, clean up deploy:finished - finished hook
  • 17. Deploy flow - Structure ├── current -> /var/www/my_app/releases/20151106114500/ ── ├── releases │ │ ├── 20151103072500 │ │ ├── 20151104083000 │ │ ├── 20151105093500 │ │ ├── 20151106104000 │ │ └── 20151106114500 ─────────────────────────────────── ├── repo │ └── [VCS related data] ├── revisions.log └── shared └── [linked_files and linked_dirs]
  • 18. Rollback flow bundle exec cap prd deploy:rollback deploy:starting deploy:started deploy:reverting - revert server(s) to previous release deploy:reverted - reverted hook deploy:publishing deploy:published deploy:finishing_rollback - finish the rollback, clean up deploy:finished
  • 19. Rollback flow - Structure ├── current -> /var/www/my_app/releases/20151106104000/ ── ├── releases │ │ ├── 20151103072500 │ │ ├── 20151104083000 │ │ ├── 20151105093500 │ │ ├── 20151106104000 ─────────────────────────────────── │ └── 20151106114500 ├── repo │ └── [VCS related data] ├── revisions.log └── shared └── [linked_files and linked_dirs]
  • 22. Capfile # Composer to install drush on the server require 'capistrano/composer'
  • 23. deploy.rb set :application, 'my_app' set :repo_url, 'git@my-repo.url' # Branch to deploy set :branch, 'master' # Destination path of the application set :deploy_to, '/var/www/my_app' # Link files directory set :linked_dirs, fetch(:linked_dirs, []).push( "#{fetch(:app_path)}/sites/default/files" )
  • 24. deploy/tst.rb # Server # ====== server 'xxx.xxx.xxx.xxx', roles: %w{app db}, user: 'deploy_user' # Map composer and drush commands # =============================== SSHKit.config.command_map[:composer] = "#{shared_path.join("composer.phar")}" SSHKit.config.command_map[:drush] = "#{shared_path.join("vendor/bin/drush")}"
  • 25. Drupal specific tasks desc 'Create a database backup' task :backup_db do on roles(:app) do within current_path.join(fetch(:app_path)).join('sites/default') do execute :drush, "sql-dump --result-file=#{current_path}/backup_db.sql" end end end desc 'Set the site offline' task :site_offline do on roles(:app) do within release_path.join(fetch(:app_path)).join('sites/default') do execute :drush, "state-set system.maintenance_mode 1 -y" end end end
  • 26. Drupal specific tasks desc 'Import configuration from the config directory' task :config_import do on roles(:app) do within release_path.join(fetch(:app_path)).join('sites/default') do execute :drush, "config-import -y" end end end desc 'Clear all caches' task :cache_clear do on roles(:app) do within release_path.join(fetch(:app_path)).join('sites/default') do execute :drush, "cache-rebuild all" end end end
  • 27. Deploy flow bundle exec cap prd deploy:drupal before "deploy:starting", "drupal:backup_db" deploy:starting - start a deployment deploy:started - started hook deploy:updating - update server(s) with a new release deploy:updated - updated hook after "drupal:updated", "drupal:site_offline" after "drupal:site_offline", "drupal:update_db" after "drupal:update_db", "drupal:config_import" after "drupal:config_import", "drupal:cache_clear:all" before "deploy:publishing", "drupal:site_online" deploy:publishing - publish the new release deploy:published - published hook deploy:finishing - finish the deployment, clean up deploy:finished - finished hook
  • 28. JENKINS ${WORKSPACE}/deploy/deploy.sh -w ${WORKSPACE} -e tst deploy.sh # Go to the Capistrano folder in the workspace cd ${WORKSPACE}/deploy/capistrano # Prepare bundle bundle bundle install # Capistrano preparation bundle exec cap ${ENVIRONMENT} composer:install_executable bundle exec cap ${ENVIRONMENT} drush:install # Capistrano deploy bundle exec cap ${ENVIRONMENT} deploy:drupal exit 0
  • 29. DEMO