Merge pull request #12 from Skud/story4deploy

Story4deploy
This commit is contained in:
Skud
2012-09-15 02:48:39 -07:00
7 changed files with 176 additions and 2 deletions

52
.rvmrc Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo "rvm use 1.9.3" > .rvmrc
environment_id="ruby-1.9.3-p194@growstuffdev"
# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version="1.14.10 (stable)" # 1.10.1 seams as a safe start
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
# return 1
# }
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
if [[ $- == *i* ]] # check for interactive shells
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create use "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
# If you use bundler, this might be useful to you:
# if [[ -s Gemfile ]] && {
# ! builtin command -v bundle >/dev/null ||
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
# }
# then
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
# gem install bundler
# fi
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
# then
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
# fi

4
Capfile Normal file
View File

@@ -0,0 +1,4 @@
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks

11
Gemfile
View File

@@ -37,7 +37,8 @@ gem 'jquery-rails'
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
gem 'capistrano'
gem 'rvm-capistrano'
# To use debugger
# gem 'debugger'
@@ -50,3 +51,11 @@ gem 'devise'
# for testing
gem 'rspec-rails'
gem 'webrat'
# for phusion passenger (i.e. mod_rails) on the server
gem 'passenger'
gem 'rake'
gem 'cape'
# compile sass to css
gem 'compass'

View File

@@ -30,7 +30,16 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
builder (3.0.2)
cape (1.4.0)
capistrano (2.13.3)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
chunky_png (1.2.6)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -38,6 +47,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.3)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
daemon_controller (1.0.0)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
@@ -47,10 +61,14 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
fastthread (1.0.7)
fssm (0.2.9)
haml (3.1.7)
highline (1.6.14)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.1)
jquery-rails (2.1.2)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
@@ -62,8 +80,20 @@ GEM
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.5.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.5)
orm_adapter (0.4.0)
passenger (3.0.17)
daemon_controller (>= 1.0.0)
fastthread (>= 1.0.1)
rack
rake (>= 0.8.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -103,6 +133,8 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
rvm-capistrano (1.2.6)
capistrano (>= 2.0.0)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
@@ -136,12 +168,18 @@ PLATFORMS
DEPENDENCIES
bundler (>= 1.1.5)
cape
capistrano
coffee-rails (~> 3.2.1)
compass
devise
haml
jquery-rails
passenger
rails (= 3.2.8)
rake
rspec-rails
rvm-capistrano
sass-rails (~> 3.2.3)
sqlite3
therubyracer

53
config/deploy.rb Normal file
View File

@@ -0,0 +1,53 @@
set :application, "dev.growstuff.org"
set :repository, "https://github.com/Growstuff/growstuff.git"
set :scm, :git
set :branch, "dev"
set :user, "deploy"
set :use_sudo, false
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache
role :web, application
role :app, application
role :db, application, :primary => true # This is where Rails migrations will rue
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.3-p194@growstuffdev'
set :rvm_type, :user
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
set :bundle_dir, "/home/deploy/.rvm/gems/ruby-1.9.3-p194@growstuffdev/"
set :bundle_flags, "--deployment"
require 'bundler/capistrano'
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
# this makes it easier to run rake tasks on the server.
# just "bundle exec cap rake_task" where rake_task is eg. db:migrate
require 'cape'
Cape do
# Create Capistrano recipes for all Rake tasks.
mirror_rake_tasks :db
mirror_rake_tasks 'db:create:all', :roles => :app do |env|
env['RAILS_ENV'] = rails_env
end
mirror_rake_tasks 'db:migrate', :roles => :app do |env|
env['RAILS_ENV'] = rails_env
end
end
after :deploy, 'db:migrate'

View File

@@ -15,7 +15,7 @@ Growstuff::Application.configure do
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true

View File

@@ -0,0 +1,18 @@
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
# Select the correct item for which you use below.
# If you're not using bundler, remove it completely.
# If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'