Simple Rails Deployments with Net/SSH

Recently I created a small Rails app as a sales/marketing site for the startup I am working at. The site is very basic with just a few models and controllers. We time came to deploy the site, Capistrano felt to big, but we didn’t want to have to manually ssh in every time we had a code change. What I wanted was a way to run one command locally that would simply run a few commands on the remote server. To do this I turned to the net/ssh library.

Just drop this code in lib/tasks/deploy.rake and now a simple `$ rake deploy` will push your changes live.

4 Comments

  1. runmen
    Posted July 27, 2011 at 1:20 pm | Permalink

    Nice tip.

    What ~/.ssh/keys/yourserver.pem do?

    Why task depend on :environment? This load rails stack, but it not used in this task

  2. Posted July 27, 2011 at 3:47 pm | Permalink

    Hi Bradly, take a look at Inploy:

    http://www.github.com/dcrec1/inploy

  3. AnonyMouse
    Posted July 28, 2011 at 2:07 am | Permalink

    shouldn’t it be lib/tasks/deploy.RAKE instead of .rb?

  4. Posted July 28, 2011 at 4:53 pm | Permalink

    @runmen That is needed your needs an ssh key to connect. If you don’t use one when ssh’ing to your server, than you won’t need it with net/ssh either.

    @Diego That’s great. I hadn’t come across Inploy before. I like the simple config/deploy.rb configuration.

    @AnonyMouse Yep, you are right. Fixed!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*