Skip to content

Instantly share code, notes, and snippets.

@jfgomez86
Created November 7, 2013 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfgomez86/7362220 to your computer and use it in GitHub Desktop.
Save jfgomez86/7362220 to your computer and use it in GitHub Desktop.
Simple Capistrano 2.15 deploy.rb file, using rbenv, apache (nginx should work too) and passenger on linode (Ubuntu 12.04 LTS)
require 'bundler/capistrano'
# Config Variables
GITHUB_REPOSITORY_NAME = 'project_name'
LINODE_SERVER_HOSTNAME = 'www.host.com'
#############################################
#############################################
# General Options
set :bundle_flags, "--deployment"
set :application, GITHUB_REPOSITORY_NAME
set :deploy_to, "/the/application/path/#{application}"
set :normalize_asset_timestamps, false
set :rails_env, "production"
set :user, "deploy"
set :runner, "deploy"
set :admin_runner, "deploy"
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
ssh_options[:keys] = ["~/.ssh/id_rsa"]
ssh_options[:forward_agent] = true
# SCM Options
set :scm, :git
set :repository, "git@github.com:username/#{GITHUB_REPOSITORY_NAME}.git"
set :branch, "master"
# Roles
role :app, LINODE_SERVER_HOSTNAME
role :db, LINODE_SERVER_HOSTNAME, :primary => true
# Add Configuration Files & Compile Assets
after 'deploy:update_code' do
# Setup Configuration
run "cp #{shared_path}/config/database.yml #{release_path}/config/database.yml"
# Compile Assets
run "cd #{release_path}; RAILS_ENV=production bundle exec rake assets:precompile"
end
# Restart Passenger
deploy.task :restart, :roles => :app do
# Restart Application
run "touch #{current_path}/tmp/restart.txt"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment