A simple way to deploy your Rails applications

A simple way to deploy your Rails applications

Sometimes I prefer to use a simpler way to deploy my Rails applications instead of install and configure some complex tool (eg.: capistrano).

A very simple way to do this is creating a shell script within the /script directory, which will access the server via SHH:

#! /bin/bash
# script/deploy.sh

TAG=deployed_at_$(date +"%F_%H-%M")
git tag -m '' -a $TAG
git push --tags

ssh user@your_domain.com << 'SSH'
  cd /var/rails_apps/my_app
  rm -rf public/assets
  git pull
  bundle install --without development test
  bundle exec rake db:migrate db:seed assets:clean assets:precompile
  touch tmp/restart.txt
  git describe > public/version

After that, a tag will be created in the git repository. Now, you know exactly the date and time when it was deployed.

And you can find out which version (tag from git) is in production accessing the URL your_domain.com/version.


Update on March 8, 2013:

I’ve created another script which accepts the -q param (quick).

Comments are closed.