Friday, October 5, 2012

Deploying with Capistrano

  1. sudo gem install capistrano-ext
  2. cd yours_rails_directory
  3. capify .
  4. mkdir config/deploy
  
Now we will create two deployments staging and production and a new staging environment.

  1. touch config/deploy/staging.rb
  2. touch config/deploy/production.rb
  3. touch config/environments/staging.rb
  1. config/deploy.rb
  2. config/deploy/production.rb
  3. config/deploy/staging.rb
  4. config/environments/staging.rb:  
  5. config/databases.yml
Now run the capistrano commands to set up the deployment. 
  1. cap staging deploy:setup
    (this creates the correct directory tree)
  2. cap staging deploy:check
    (this checks to make sure setup ran)
  3. cap staging deploy:update
    (this updates the server with the app code)
  4. ssh your_user_name@your_deployment_server
    (fill in the correct user and server here)
  5. cd your_deployment_directory/current
    (again fill in the correct deploy to dir)
  6. RAILS_ENV=staging sudo rake gems:install
    (this installs gems that need native compiling)
  7. RAILS_ENV=staging rake db:schema:load
    (loads the database)
  8. RAILS_ENV=staging rake db:seed
    (loads any seed data)
  9. script/console staging
    (load the console for testing)
  10. app.get('/')
    (test to see if this returns ‘200’)
  11. exit
    (exit the console)
  12. exit
    (exit ssh)
  13. cap staging deploy:restart

1 comment:

  1. Hi there!
    We launched a RailsRumble project about a month ago called DeployButton, that's getting a fair number of active users deploying using Capistrano every day.

    If you end up using it, please drop us a line and give us your feedback on new features that you'd like to see developed for it! :)

    Thanks,
    Ash

    --
    DeployButton.com makes continuous delivery easy with a single button.

    ReplyDelete