SlideShare una empresa de Scribd logo
1 de 29
Deploy Drupal with
   Capistrano
      a year later
“A life without philosophy
Capistrano is not worth living”
            --Socrates
“A life without philosophy
Capistrano is not worth living”
            --Socrates


 “Drupal is worth the PHPain”
     --Anonymous from Bari
The Actors
Our friend
Our friend

 Kick Ass CMS
Our friend

     Kick Ass CMS




Isn’t very deploy friendly
Our friend

     Kick Ass CMS




Isn’t very deploy friendly
 and needs some help...
His friend

 Kick Ass CMS
His friend

 Kick Ass CMS




 The logo sucks
His friend

         Kick Ass CMS




           The logo sucks
but it will help your deployments!
The Target
$ cap intinig production deploy
capistrano


   $ cap intinig production deploy
capistrano


   $ cap intinig production deploy
             developer
capistrano               stage


   $ cap intinig production deploy
             developer
capistrano               stage


   $ cap intinig production deploy
             developer           command
The Code
Capfile
                   where the fun starts
load 'deploy' if respond_to?(:namespace) # cap2 differentiator

load   'includes/recipes/stages'
load   'includes/recipes/mikamai'
load   'includes/recipes/drupal'
load   'includes/recipes/overrides'
load   'includes/recipes/devs'

# SCM Stuff configure to taste, just remember the repository
set :repository, "git@github.com:mikamai/app.git"
set :scm, :git
set :branch, "master"
set :repository_cache, "git_master"
set :deploy_via, :remote_cache
set :scm_verbose, true
set :keep_releases, 3
includes/recipes
where we put the “Good Stuff”™
devs.rb
           let’s tell capistrano about ourselves

task :intinig do
 set :local_mysqldump, "/usr/local/mysql/bin/mysqldump"
 set :local_db_user, "root"
 set :local_db_password, "youwishItoldyou"
 set :local_db_name, "app_db"
end

task :paolo do
 set :local_mysqldump, "/Applications/MAMP/Library/bin/mysqldump"
 set :local_db_user, "root"
 set :local_db_password, "paolo"
 set :local_db_name, "stefano"
end
drupal.rb
change capistrano default behavior
 load File.dirname(__FILE__) + '/drupal/db'
 load File.dirname(__FILE__) + '/drupal/configure'

 after 'deploy:setup', 'drupal:setup'
 after 'deploy:symlink', 'drupal:symlink'
 before 'deploy:start', 'drupal:db:import:production'

 before 'deploy:restart', 'drupal:configure:stage'
 before 'deploy:start', 'drupal:configure:stage'

 namespace :drupal do
  task :setup, :except => { :no_release => true } do
   sudo "mkdir -p #{shared_path}/files"
   sudo "chmod a+w #{shared_path}/files"

   sudo "mkdir -p #{shared_path}/dumps"

   sudo "chown -R #{user}:#{user} #{deploy_to}"
  end

  task :symlink, :except => { :no_release => true } do
   sudo "ln -s #{shared_path}/files #{latest_release}"
  end
 end
drupal/configure.rb
                    a small hack for multiple stages
namespace :drupal do
 namespace :configure do
  task :stage do
    source = "#{latest_release}/sites/default/settings.#{stage_name}.php"
    dest = "#{latest_release}/sites/default/settings.php"
    sudo "cp #{source} #{dest}"
  end
 end
end
drupal/db.rb
                                       mysql grinding
namespace :local do
 desc "Dumps the local database"
 task :default, :roles => :db do
  raise RuntimeError.new("failed dump") unless system "#{local_mysqldump} -u #{local_db_user} --
password=#{local_db_password} #{local_db_name} > dump.local.sql"
 end

 namespace :upload do
  desc "Dumps and uploads the local database"
  task :default do
    drupal::db::dump::local::default
    put(File.read("dump.local.sql"), "#{shared_path}/dumps/dump.local.sql")
    run "mysql -u #{db_user} --password=#{db_password} #{db_name} < #{shared_path}/dumps/
dump.local.sql"
  end
 end
end
drupal/db.rb
                                     mysql grinding / 2
namespace :remote do
 desc "Dumps the remote database"
 task :default, :roles => :db do
  filename = "#{Time.now.to_i.to_s}.dump.sql"
  run "cd #{shared_path}/dumps; #{remote_mysqldump} -u #{db_user} --password=#{db_password}
#{db_name} > #{filename}"
  run "cd #{shared_path}/dumps; bzip2 #{filename}"
 end

 namespace :download do
  desc "Dumps and downloads the remote database"
  task :default do
   drupal::db::dump::remote::default
   latest
  end

  desc "Downloads the latest database dump"
  task :latest, :roles => :db do
    dumps = capture("ls -xt #{shared_path}/dumps").split.reverse
    get("#{shared_path}/dumps/#{dumps.last}", "./#{dumps.last}")
  end
 end
end
mikamai.rb
             fix problems on our servers
before 'deploy:restart', 'mikamai:permissions:fix'
before 'deploy:start', 'mikamai:permissions:fix'

namespace :mikamai do

 namespace :production do
  task :symlink, :except => { :no_release => true } do
   sudo "rm -rf /var/www/#{application}"
   sudo "ln -s #{latest_release} /var/www/#{application}"
  end
 end

 namespace :permissions do
  task :fix, :except => { :no_release => true } do
   sudo "chown -R www-data:www-data #{latest_release}"
  end
 end

end
overrides.rb
                      do as we say not as we do
namespace :deploy do
 task :finalize_update, :except => { :no_release => true } do
  sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
 end

 task :cold do
  update
  start
 end

 task :restart do
 end

 task :start do
 end
end
stages.rb
                    one for everyone
set :application, "cool_app"

desc "deploy to development environment"
task :development do
 set :stage_name, "development"

 role :web, "danton.mikamai.com:8888", :primary => true
 role :db, "danton.mikamai.com:8888", :primary => true
 set :user, "drupal"
 set :password, "secret"
 set :remote_mysqldump, "/usr/bin/mysqldump"
 set :deploy_to, "/var/apps/#{application}"
 set :db_user, "dbuser"
 set :db_password, "supersecret"
 set :db_name, "appname"
end
Questions?
Giovanni Intini <giovanni@mikamai.com>

Más contenido relacionado

Último

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Último (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

Destacado

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
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 HealthThinkNow
 
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.pdfmarketingartwork
 
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 2024Neil Kimberley
 
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)contently
 
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 2024Albert Qian
 
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 InsightsKurio // The Social Media Age(ncy)
 
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 2024Search Engine Journal
 
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 summarySpeakerHub
 
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 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 Tessa Mero
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
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 managementMindGenius
 
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...RachelPearson36
 
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...Applitools
 

Destacado (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
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...
 

Deploy Drupal With Capistrano A Year Later

  • 1. Deploy Drupal with Capistrano a year later
  • 2. “A life without philosophy Capistrano is not worth living” --Socrates
  • 3. “A life without philosophy Capistrano is not worth living” --Socrates “Drupal is worth the PHPain” --Anonymous from Bari
  • 6. Our friend Kick Ass CMS
  • 7. Our friend Kick Ass CMS Isn’t very deploy friendly
  • 8. Our friend Kick Ass CMS Isn’t very deploy friendly and needs some help...
  • 9. His friend Kick Ass CMS
  • 10. His friend Kick Ass CMS The logo sucks
  • 11. His friend Kick Ass CMS The logo sucks but it will help your deployments!
  • 13. $ cap intinig production deploy
  • 14. capistrano $ cap intinig production deploy
  • 15. capistrano $ cap intinig production deploy developer
  • 16. capistrano stage $ cap intinig production deploy developer
  • 17. capistrano stage $ cap intinig production deploy developer command
  • 19. Capfile where the fun starts load 'deploy' if respond_to?(:namespace) # cap2 differentiator load 'includes/recipes/stages' load 'includes/recipes/mikamai' load 'includes/recipes/drupal' load 'includes/recipes/overrides' load 'includes/recipes/devs' # SCM Stuff configure to taste, just remember the repository set :repository, "git@github.com:mikamai/app.git" set :scm, :git set :branch, "master" set :repository_cache, "git_master" set :deploy_via, :remote_cache set :scm_verbose, true set :keep_releases, 3
  • 20. includes/recipes where we put the “Good Stuff”™
  • 21. devs.rb let’s tell capistrano about ourselves task :intinig do set :local_mysqldump, "/usr/local/mysql/bin/mysqldump" set :local_db_user, "root" set :local_db_password, "youwishItoldyou" set :local_db_name, "app_db" end task :paolo do set :local_mysqldump, "/Applications/MAMP/Library/bin/mysqldump" set :local_db_user, "root" set :local_db_password, "paolo" set :local_db_name, "stefano" end
  • 22. drupal.rb change capistrano default behavior load File.dirname(__FILE__) + '/drupal/db' load File.dirname(__FILE__) + '/drupal/configure' after 'deploy:setup', 'drupal:setup' after 'deploy:symlink', 'drupal:symlink' before 'deploy:start', 'drupal:db:import:production' before 'deploy:restart', 'drupal:configure:stage' before 'deploy:start', 'drupal:configure:stage' namespace :drupal do task :setup, :except => { :no_release => true } do sudo "mkdir -p #{shared_path}/files" sudo "chmod a+w #{shared_path}/files" sudo "mkdir -p #{shared_path}/dumps" sudo "chown -R #{user}:#{user} #{deploy_to}" end task :symlink, :except => { :no_release => true } do sudo "ln -s #{shared_path}/files #{latest_release}" end end
  • 23. drupal/configure.rb a small hack for multiple stages namespace :drupal do namespace :configure do task :stage do source = "#{latest_release}/sites/default/settings.#{stage_name}.php" dest = "#{latest_release}/sites/default/settings.php" sudo "cp #{source} #{dest}" end end end
  • 24. drupal/db.rb mysql grinding namespace :local do desc "Dumps the local database" task :default, :roles => :db do raise RuntimeError.new("failed dump") unless system "#{local_mysqldump} -u #{local_db_user} -- password=#{local_db_password} #{local_db_name} > dump.local.sql" end namespace :upload do desc "Dumps and uploads the local database" task :default do drupal::db::dump::local::default put(File.read("dump.local.sql"), "#{shared_path}/dumps/dump.local.sql") run "mysql -u #{db_user} --password=#{db_password} #{db_name} < #{shared_path}/dumps/ dump.local.sql" end end end
  • 25. drupal/db.rb mysql grinding / 2 namespace :remote do desc "Dumps the remote database" task :default, :roles => :db do filename = "#{Time.now.to_i.to_s}.dump.sql" run "cd #{shared_path}/dumps; #{remote_mysqldump} -u #{db_user} --password=#{db_password} #{db_name} > #{filename}" run "cd #{shared_path}/dumps; bzip2 #{filename}" end namespace :download do desc "Dumps and downloads the remote database" task :default do drupal::db::dump::remote::default latest end desc "Downloads the latest database dump" task :latest, :roles => :db do dumps = capture("ls -xt #{shared_path}/dumps").split.reverse get("#{shared_path}/dumps/#{dumps.last}", "./#{dumps.last}") end end end
  • 26. mikamai.rb fix problems on our servers before 'deploy:restart', 'mikamai:permissions:fix' before 'deploy:start', 'mikamai:permissions:fix' namespace :mikamai do namespace :production do task :symlink, :except => { :no_release => true } do sudo "rm -rf /var/www/#{application}" sudo "ln -s #{latest_release} /var/www/#{application}" end end namespace :permissions do task :fix, :except => { :no_release => true } do sudo "chown -R www-data:www-data #{latest_release}" end end end
  • 27. overrides.rb do as we say not as we do namespace :deploy do task :finalize_update, :except => { :no_release => true } do sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) end task :cold do update start end task :restart do end task :start do end end
  • 28. stages.rb one for everyone set :application, "cool_app" desc "deploy to development environment" task :development do set :stage_name, "development" role :web, "danton.mikamai.com:8888", :primary => true role :db, "danton.mikamai.com:8888", :primary => true set :user, "drupal" set :password, "secret" set :remote_mysqldump, "/usr/bin/mysqldump" set :deploy_to, "/var/apps/#{application}" set :db_user, "dbuser" set :db_password, "supersecret" set :db_name, "appname" end