SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
Deploy Drupal with
   Capistrano
      and live to tell
“A life without philosophy Capistrano is 
            not worth living” 
               --Socrates
The plan

• Throw away what we don’t need
• Keep it simple
• ???
• Profit!
Standard stuff
“non ragioniam di lor, ma guarda e passa”




1
load
'deploy'
if
respond_to?(:namespace)
#
cap2
differentiator




2





3
#
You
should
probably
configure
these




4
set
:user,
quot;drupalquot;




5
set
:password,
quot;supersecretquot;




6
set
:application,
quot;my.application.namequot;




7





8
#
The
default
should
be
ok




9
set
:deploy_to,
quot;/var/apps/#{application}quot;



10




11
#
SCM
Stuff
configure
to
taste,
just
remember
the
repository



12
set
:repository,

quot;git@github.com:intinig/app.gitquot;



13
set
:scm,
:git



14
set
:branch,
quot;masterquot;



15
set
:repository_cache,
quot;git_masterquot;



16
set
:deploy_via,
:remote_cache



17
set
:scm_verbose,
true



18




19
#
Single
server
setup



20
role
:web,
quot;danton.mikamai.com:8888quot;,
:primary
=>
true
Callbacks
                                     The Juice




22
#
Callbacks



23
after
'deploy:setup',
'drupal:setup'



24
after
'deploy:symlink',
'drupal:symlink'



25
before
'deploy:start',
'drupal:db:import:production'



26




27
before
'deploy:restart',
'mikamai:permissions:fix'



28
before
'deploy:restart',
'mikamai:production:symlink',
'drupal:configure:production'



29
before
'deploy:start',
'mikamai:permissions:fix'



30
before
'deploy:start',
'mikamai:production:symlink',
'drupal:configure:production'



31
before
'deploy:cold',
'drupal:db:dump:development'
Overriding
                      Who’s your daddy?



85
namespace
:deploy
do



86


task
:finalize_update,
:except
=>
{
:no_release
=>
true
}
do



87




sudo
quot;chmod
‐R
g+w
#{latest_release}quot;
if
fetch(:group_writable,

true)



88


end



89






90


task
:cold
do



91




update



92




start



93


end



94






95


task
:restart
do



96


end



97






98


task
:start
do



99


end


100
end
The (long) Drupal namespace




48
namespace
:drupal
do



49


task
:setup,
:except
=>
{
:no_release
=>
true
}
do



50




sudo
quot;mkdir
‐p
#{shared_path}/filesquot;



51




sudo
quot;chown
‐R
#{user}:#{user}
#{deploy_to}quot;



52


end



53






54


task
:symlink,
:except
=>
{
:no_release
=>
true
}
do



55




sudo
quot;ln
‐s
#{shared_path}/files
#{latest_release}quot;



56


end



57






58


namespace
:configure
do



59




task
:production
do



60






sudo
quot;cd
#{latest_release}/sites/default;
cp
settings.production.php
settings.phpquot;



61




end



62








63




task
:development
do



64






sudo
quot;cd
#{latest_release}/sites/default;
cp
settings.development.php
settings.phpquot;



65




end



66


end
Still the (long) Drupal namespace





68


namespace
:db
do



69




namespace
:dump
do



70






task
:development
do



71








raise
RuntimeError.new(quot;failed
dumpquot;)
unless
system
...



72






end



73




end



74








75




namespace
:import
do



76






task
:production
do



77








ENV[quot;FILESquot;]
=
quot;dump.sqlquot;



78








deploy::upload



79








run
quot;mysql
‐u
#{db_user}
‐‐password=#{db_password}
...quot;



80






end



81




end



82


end



83
end
Last, but not least...
How we do it in
       Mikamai


102
namespace
:mikamai
do


103





104


namespace
:production
do


105




task
:symlink,
:except
=>
{
:no_release
=>
true
}
do


106






sudo
quot;rm
‐rf
/var/www/#{application}quot;


107






sudo
quot;ln
‐s
#{latest_release}
/var/www/#{application}quot;


108




end


109


end


110





111


namespace
:permissions
do


112




task
:fix,
:except
=>
{
:no_release
=>
true
}
do


113






sudo
quot;chown
‐R
www‐data:www‐data
#{latest_release}quot;


114




end


115


end


116





117
end
Questions?
Giovanni Intini <giovanni@mikamai.com>

Más contenido relacionado

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Deploy Drupal With Capistrano

  • 1. Deploy Drupal with Capistrano and live to tell
  • 2. “A life without philosophy Capistrano is  not worth living”  --Socrates
  • 3. The plan • Throw away what we don’t need • Keep it simple • ??? • Profit!
  • 4. Standard stuff “non ragioniam di lor, ma guarda e passa” 



1
load
'deploy'
if
respond_to?(:namespace)
#
cap2
differentiator 



2
 



3
#
You
should
probably
configure
these 



4
set
:user,
quot;drupalquot; 



5
set
:password,
quot;supersecretquot; 



6
set
:application,
quot;my.application.namequot; 



7
 



8
#
The
default
should
be
ok 



9
set
:deploy_to,
quot;/var/apps/#{application}quot; 


10
 


11
#
SCM
Stuff
configure
to
taste,
just
remember
the
repository 


12
set
:repository,

quot;git@github.com:intinig/app.gitquot; 


13
set
:scm,
:git 


14
set
:branch,
quot;masterquot; 


15
set
:repository_cache,
quot;git_masterquot; 


16
set
:deploy_via,
:remote_cache 


17
set
:scm_verbose,
true 


18
 


19
#
Single
server
setup 


20
role
:web,
quot;danton.mikamai.com:8888quot;,
:primary
=>
true
  • 5. Callbacks The Juice 


22
#
Callbacks 


23
after
'deploy:setup',
'drupal:setup' 


24
after
'deploy:symlink',
'drupal:symlink' 


25
before
'deploy:start',
'drupal:db:import:production' 


26
 


27
before
'deploy:restart',
'mikamai:permissions:fix' 


28
before
'deploy:restart',
'mikamai:production:symlink',
'drupal:configure:production' 


29
before
'deploy:start',
'mikamai:permissions:fix' 


30
before
'deploy:start',
'mikamai:production:symlink',
'drupal:configure:production' 


31
before
'deploy:cold',
'drupal:db:dump:development'
  • 6. Overriding Who’s your daddy? 


85
namespace
:deploy
do 


86


task
:finalize_update,
:except
=>
{
:no_release
=>
true
}
do 


87




sudo
quot;chmod
‐R
g+w
#{latest_release}quot;
if
fetch(:group_writable,
 true) 


88


end 


89


 


90


task
:cold
do 


91




update 


92




start 


93


end 


94


 


95


task
:restart
do 


96


end 


97


 


98


task
:start
do 


99


end 

100
end
  • 7. The (long) Drupal namespace 


48
namespace
:drupal
do 


49


task
:setup,
:except
=>
{
:no_release
=>
true
}
do 


50




sudo
quot;mkdir
‐p
#{shared_path}/filesquot; 


51




sudo
quot;chown
‐R
#{user}:#{user}
#{deploy_to}quot; 


52


end 


53


 


54


task
:symlink,
:except
=>
{
:no_release
=>
true
}
do 


55




sudo
quot;ln
‐s
#{shared_path}/files
#{latest_release}quot; 


56


end 


57


 


58


namespace
:configure
do 


59




task
:production
do 


60






sudo
quot;cd
#{latest_release}/sites/default;
cp
settings.production.php
settings.phpquot; 


61




end 


62




 


63




task
:development
do 


64






sudo
quot;cd
#{latest_release}/sites/default;
cp
settings.development.php
settings.phpquot; 


65




end 


66


end
  • 8. Still the (long) Drupal namespace 


68


namespace
:db
do 


69




namespace
:dump
do 


70






task
:development
do 


71








raise
RuntimeError.new(quot;failed
dumpquot;)
unless
system
... 


72






end 


73




end 


74




 


75




namespace
:import
do 


76






task
:production
do 


77








ENV[quot;FILESquot;]
=
quot;dump.sqlquot; 


78








deploy::upload 


79








run
quot;mysql
‐u
#{db_user}
‐‐password=#{db_password}
...quot; 


80






end 


81




end 


82


end 


83
end
  • 9. Last, but not least...
  • 10. How we do it in Mikamai 

102
namespace
:mikamai
do 

103


 

104


namespace
:production
do 

105




task
:symlink,
:except
=>
{
:no_release
=>
true
}
do 

106






sudo
quot;rm
‐rf
/var/www/#{application}quot; 

107






sudo
quot;ln
‐s
#{latest_release}
/var/www/#{application}quot; 

108




end 

109


end 

110


 

111


namespace
:permissions
do 

112




task
:fix,
:except
=>
{
:no_release
=>
true
}
do 

113






sudo
quot;chown
‐R
www‐data:www‐data
#{latest_release}quot; 

114




end 

115


end 

116


 

117
end