SlideShare a Scribd company logo
1 of 19
Download to read offline
Deploying Your Apps 
(With Capistrano) 
David Underwood @davefp
What is 'Deployment'? 
David Underwood @davefp
Deployment is the 
process of 
distributing and 
starting your app in 
an environment 
David Underwood @davefp
What Steps do we Need? 
David Underwood @davefp
What do you do in 
development? 
David Underwood @davefp
One-Time Operations 
—Provision server. 
—Set up database and other supporting 
services. 
—Create credentials for external 
services. 
David Underwood @davefp
Per-Deploy Operations 
—Fetch new code. 
—Run migrations. 
—Update configuration. 
—Restart (or stop/start) app. 
David Underwood @davefp
Capistrano 
David Underwood @davefp
The Basics 
Add it to your gemfile: 
gem 'capistrano' 
Get it installed: 
bundle install 
bundle exec cap install 
David Underwood @davefp
Anatomy of a Command 
Specify a stage, and a task to run on it: 
cap production deploy 
cap staging deploy:migrate 
cap custom_stage custom_namespace:custom_task 
David Underwood @davefp
Configuration 
Your Capfile contains any includes you 
might need. 
require 'capistrano/setup' 
require 'capistrano/deploy' 
require 'capistrano/rbenv' 
require 'capistrano/rails' 
require 'capistrano3/unicorn' 
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } 
David Underwood @davefp
Configuration common to all states is 
found in config/deploy.rb. 
lock '3.2.1' 
set :application, 'arenagym' 
set :repo_url, 'git@bitbucket.org:davefp/arenagym.git' 
set :linked_files, %w{config/database.yml .env} 
set :linked_dirs, %w{tmp/pids} 
set :unicorn_config_path, "config/unicorn.rb" 
set :unicorn_rails, true 
set :rbenv_type, :user 
set :rbenv_ruby, '2.1.1' 
set :rbenv_map_bins, %w{rake gem bundle ruby rails} 
set :rbenv_roles, :all # default value 
David Underwood @davefp
Environment/stage specific config in 
named files, e.g. config/deploy/ 
production.rb 
set :stage, :production 
set :deploy_to, '~/apps/arenagym' 
set :branch, 'master' 
set :rails_env, 'production' 
# Simple Role Syntax 
# ================== 
# Supports bulk-adding hosts to roles, the primary 
# server in each group is considered to be the first 
# unless any hosts have the primary property set. 
role :app, %w{deploy@arenagym.net:2222} 
role :web, %w{deploy@arenagym.net:2222} 
role :db, %w{deploy@arenagym.net:2222} 
David Underwood @davefp
Take a look at the 
deploy task: 
Handy Link 
David Underwood @davefp
Linked Files 
Linked files are any files that are not part 
of your codebase that you need to run 
your app. 
They persist from deploy to deploy. 
—database.yml 
—.env, config.yml, or secrets.yml 
—pid files (e.g. for unicorn restarts) 
David Underwood @davefp
Deploys 
Each time you deploy, your code is put in 
a new folder alongside the old stuff. 
When everything is ready, this folder is 
symlinked to the 'current' folder to 
minimise downtime. 
A certain number of previous releases 
are kept around so that you can roll 
back. 
David Underwood @davefp
Tailoring Capistrano to your needs 
—capistrano/rails provides migration and 
asset tasks. 
—capistrano3/unicorn provides app 
server start, stop, restart tasks. 
—Etc.. 
David Underwood @davefp
Questions? 
David Underwood @davefp
Thanks! 
Capistrano site: capistranorb.com 
This presentation: On my GitHub 
My blog: theflyingdeveloper.com 
David Underwood @davefp

More Related Content

What's hot

Zenith Arca Business Introduction
Zenith Arca Business IntroductionZenith Arca Business Introduction
Zenith Arca Business Introduction
sgo4th
 

What's hot (20)

Testing in Infrastructure
Testing in InfrastructureTesting in Infrastructure
Testing in Infrastructure
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Heroku + Jeweler & Gemcutter
Heroku + Jeweler & GemcutterHeroku + Jeweler & Gemcutter
Heroku + Jeweler & Gemcutter
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
 
Configuration Management and Salt
Configuration Management and SaltConfiguration Management and Salt
Configuration Management and Salt
 
Learn How Selenium And Jenkins Fit In DevOps | Edureka Live
Learn How Selenium And Jenkins Fit In DevOps | Edureka LiveLearn How Selenium And Jenkins Fit In DevOps | Edureka Live
Learn How Selenium And Jenkins Fit In DevOps | Edureka Live
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef Stuff
 
Continuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at NetflixContinuously Integrating Distributed Code at Netflix
Continuously Integrating Distributed Code at Netflix
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Infrastructure as Code with Chef
Infrastructure as Code with ChefInfrastructure as Code with Chef
Infrastructure as Code with Chef
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
 
Code Reviews vs. Pull Requests
Code Reviews vs. Pull RequestsCode Reviews vs. Pull Requests
Code Reviews vs. Pull Requests
 
Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed Chef
 
Advanced WordPress Tooling
Advanced WordPress ToolingAdvanced WordPress Tooling
Advanced WordPress Tooling
 
Compliance Automation with InSpec
Compliance Automation with InSpecCompliance Automation with InSpec
Compliance Automation with InSpec
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Zenith Arca Business Introduction
Zenith Arca Business IntroductionZenith Arca Business Introduction
Zenith Arca Business Introduction
 
Automating secure server baselines with Chef
Automating secure server baselines with ChefAutomating secure server baselines with Chef
Automating secure server baselines with Chef
 
Chef Delivery
Chef DeliveryChef Delivery
Chef Delivery
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 

Viewers also liked

Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
Almir Mendes
 
E co p presentation final
E co p presentation finalE co p presentation final
E co p presentation final
aletom78
 
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008aNewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
Blog NewsGames
 
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
TheFamily
 

Viewers also liked (12)

Software Livre, que história é essa?
Software Livre, que história é essa?Software Livre, que história é essa?
Software Livre, que história é essa?
 
Cucumber @ VilniusPHP
Cucumber @ VilniusPHPCucumber @ VilniusPHP
Cucumber @ VilniusPHP
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
Podcast 39 – Games As Oases For Journalists
Podcast 39 – Games As Oases For JournalistsPodcast 39 – Games As Oases For Journalists
Podcast 39 – Games As Oases For Journalists
 
Swede
SwedeSwede
Swede
 
Capistrano for non-rubyist
Capistrano for non-rubyistCapistrano for non-rubyist
Capistrano for non-rubyist
 
Ruby.new @ VilniusRB
Ruby.new @ VilniusRBRuby.new @ VilniusRB
Ruby.new @ VilniusRB
 
E co p presentation final
E co p presentation finalE co p presentation final
E co p presentation final
 
test
testtest
test
 
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008aNewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
NewsGames - Demarcando um novo modelo de Jornalismo Online - Novembro de 2008a
 
NewTwitter como motor textual dos NewsGames - substituição de feeds RSS por m...
NewTwitter como motor textual dos NewsGames - substituição de feeds RSS por m...NewTwitter como motor textual dos NewsGames - substituição de feeds RSS por m...
NewTwitter como motor textual dos NewsGames - substituição de feeds RSS por m...
 
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
Les Barbares Attaquent l'Education ! Par Oussama Ammar, co-fondateur de TheFa...
 

Similar to Deploying Your Webapps (with Capistrano)

Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
Jace Ju
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Simon Boulet
 
Ranger admin dev overview
Ranger admin dev overviewRanger admin dev overview
Ranger admin dev overview
Tushar Dudhatra
 

Similar to Deploying Your Webapps (with Capistrano) (20)

Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Hosting Your Own OTA Update Service
Hosting Your Own OTA Update ServiceHosting Your Own OTA Update Service
Hosting Your Own OTA Update Service
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
iOSDevCamp Firebase Overview
iOSDevCamp Firebase OverviewiOSDevCamp Firebase Overview
iOSDevCamp Firebase Overview
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with Features
 
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
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 
Zend framework
Zend frameworkZend framework
Zend framework
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
 
WP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of DeveloperWP-CLI - A Good Friend of Developer
WP-CLI - A Good Friend of Developer
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Commcon 2018
Commcon 2018Commcon 2018
Commcon 2018
 
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
 
Ranger admin dev overview
Ranger admin dev overviewRanger admin dev overview
Ranger admin dev overview
 
Deploy like a pro!
Deploy like a pro!Deploy like a pro!
Deploy like a pro!
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 

Recently uploaded

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Recently uploaded (20)

Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphGraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...Incident handling is a clearly defined set of procedures to manage and respon...
Incident handling is a clearly defined set of procedures to manage and respon...
 

Deploying Your Webapps (with Capistrano)

  • 1. Deploying Your Apps (With Capistrano) David Underwood @davefp
  • 2. What is 'Deployment'? David Underwood @davefp
  • 3. Deployment is the process of distributing and starting your app in an environment David Underwood @davefp
  • 4. What Steps do we Need? David Underwood @davefp
  • 5. What do you do in development? David Underwood @davefp
  • 6. One-Time Operations —Provision server. —Set up database and other supporting services. —Create credentials for external services. David Underwood @davefp
  • 7. Per-Deploy Operations —Fetch new code. —Run migrations. —Update configuration. —Restart (or stop/start) app. David Underwood @davefp
  • 9. The Basics Add it to your gemfile: gem 'capistrano' Get it installed: bundle install bundle exec cap install David Underwood @davefp
  • 10. Anatomy of a Command Specify a stage, and a task to run on it: cap production deploy cap staging deploy:migrate cap custom_stage custom_namespace:custom_task David Underwood @davefp
  • 11. Configuration Your Capfile contains any includes you might need. require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/rbenv' require 'capistrano/rails' require 'capistrano3/unicorn' Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } David Underwood @davefp
  • 12. Configuration common to all states is found in config/deploy.rb. lock '3.2.1' set :application, 'arenagym' set :repo_url, 'git@bitbucket.org:davefp/arenagym.git' set :linked_files, %w{config/database.yml .env} set :linked_dirs, %w{tmp/pids} set :unicorn_config_path, "config/unicorn.rb" set :unicorn_rails, true set :rbenv_type, :user set :rbenv_ruby, '2.1.1' set :rbenv_map_bins, %w{rake gem bundle ruby rails} set :rbenv_roles, :all # default value David Underwood @davefp
  • 13. Environment/stage specific config in named files, e.g. config/deploy/ production.rb set :stage, :production set :deploy_to, '~/apps/arenagym' set :branch, 'master' set :rails_env, 'production' # Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary # server in each group is considered to be the first # unless any hosts have the primary property set. role :app, %w{deploy@arenagym.net:2222} role :web, %w{deploy@arenagym.net:2222} role :db, %w{deploy@arenagym.net:2222} David Underwood @davefp
  • 14. Take a look at the deploy task: Handy Link David Underwood @davefp
  • 15. Linked Files Linked files are any files that are not part of your codebase that you need to run your app. They persist from deploy to deploy. —database.yml —.env, config.yml, or secrets.yml —pid files (e.g. for unicorn restarts) David Underwood @davefp
  • 16. Deploys Each time you deploy, your code is put in a new folder alongside the old stuff. When everything is ready, this folder is symlinked to the 'current' folder to minimise downtime. A certain number of previous releases are kept around so that you can roll back. David Underwood @davefp
  • 17. Tailoring Capistrano to your needs —capistrano/rails provides migration and asset tasks. —capistrano3/unicorn provides app server start, stop, restart tasks. —Etc.. David Underwood @davefp
  • 19. Thanks! Capistrano site: capistranorb.com This presentation: On my GitHub My blog: theflyingdeveloper.com David Underwood @davefp