Skip to content

Instantly share code, notes, and snippets.

@7hunderbird
Created April 15, 2009 18:13
Show Gist options
  • Save 7hunderbird/95932 to your computer and use it in GitHub Desktop.
Save 7hunderbird/95932 to your computer and use it in GitHub Desktop.
deploy.rb
# a quick and easy way to to multi-stage deployments
# the basics
set :keep_releases, 5
set :application, "app_name"
set :user, "deploy_user"
set :password, "the_one_you_use"
set :deploy_to, "/data/#{application}"
# if using git, otherwise substitute your scm
set :repository, "git://github.com/user/repo_name.git"
set :scm_username, ""
set :scm_password, ""
set :scm, :git
# this will execute the Git revision parsing on the *remote* server rather than locally
set :real_revision, lambda { source.query_revision(revision) { |cmd| capture(cmd) } }
# database configuration
set :development_database, "app_name_development"
set :development_dbhost, "mysql.domain.com"
set :production_database, "app_name_production"
set :production_dbhost, "mysql.domain.com"
set :dbuser, "user_name_db"
set :dbpass, "that_password_used"
# comment out if it gives you trouble. newest net/ssh needs this set.
ssh_options[:paranoid] = false
# this is where the "roles" are defined.
task :development do
namespace :deploy do
task :symlink_configs do
# leave blank like this.
end
end
# use localhost or your local IP address
role :web, "localhost"
role :app, "localhost"
role :db , "localhost", :primary => true
set :rails_env, "development"
set :environment_database, defer { development_database }
set :environment_dbhost, defer { development_dbhost }
end
task :production do
# use the IP address (and possibly port)
role :web, "1.2.3.4"
role :app, "1.2.3.4"
role :db , "1.2.3.4", :primary => true
set :rails_env, "production"
set :environment_database, defer { production_database }
set :environment_dbhost, defer { production_dbhost }
end
# call the stage by typing..
cap development deploy
# or
cap production deploy
# wash, rinse, repeat!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment