Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Two-Step Deployment with Rails

622 views

Published on

A 5-minute "lightning talk". Very briefly shows how we package a Rails app on a build server, then RSync the app package to our staging and production environments.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Two-Step Deployment with Rails

  1. 1. Two-Step Deployment for RailsDoug Smithhttp://daveramsey.com
  2. 2. Classic Capistrano One-Step ProcessExport code from GithubAsset Precompileetc., etc.Staging ProductionExport code from GithubAsset Precompileetc., etc.$ cap deploy
  3. 3. Problems With Classic Approach• Staging and Production might run different code• Production requires extra dependencies
  4. 4. Two-Step Process1. Build deployable “package”2. Deploy same package to all environments
  5. 5. Why Two Steps?• Consistent code package deployed• Fewer dependencies on production
  6. 6. Build ProcessExport code from GithubRun Entire Test SuiteAsset Precompilebundle install --deployment$ cap build deploy
  7. 7. Deploy Built Package To ServersBuildStaging Production
  8. 8. Deploy ProcessRSync built app to serverGraceful Unicorn restart$ cap staging deploy -s release_name="20130430172348"
  9. 9. RSync Task: production environmentsnamespace :deploy dodesc <<-DESCUpdate all servers with the latest release of the source code.Since production servers do not have access to SCM, we usersync to push to code to the servers.DESCtask :update_code, :roles => [:app, :web] doon_rollback { run "rm -rf #{release_path}; true" }username = user || ENV[USER]run <<-CMDrsync -avz -e ssh #{Dir.pwd}/ #{username}@$CAPISTRANO:HOST$:#{release_path} --exclude log --exclude tmp--exclude public/assets --exclude public/files --exclude public/systemCMDhttps://gist.github.com/dugsmith/5109521
  10. 10. Summary1. Build once2. Deploy same package everywhere
  11. 11. Follow-up• http://slidesha.re/Ylgipm• doug.smith@daveramsey.com• @arogos• http://developwithpurpose.com

×