Created
November 7, 2013 21:35
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "[email protected]: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