Commit 313ff1e9

mo khan <mo@mokhan.ca>
2013-07-27 20:12:07
user rbenv instead of rvm
1 parent a8f2a0f
config/recipes/rbenv.rb
@@ -0,0 +1,40 @@
+set_default :ruby_version, "2.0.0-p247"
+
+namespace :rbenv do
+  desc "install rbenv"
+  task :install, roles: :app do
+    # Install development tools:
+    run "#{sudo} apt-get -y install build-essential"
+    # Packages required for compilation of some stdlib modules
+    run "#{sudo} apt-get -y install tklib"
+    # Extras for RubyGems and Rails:
+    run "#{sudo} apt-get -y install zlib1g-dev libssl-dev"
+    # Readline Dev on Ubuntu 12.04 LTS:
+    run "#{sudo} apt-get -y install libreadline-gplv2-dev"
+    # Install some nokogiri dependencies:
+    run "#{sudo} apt-get -y install libxml2 libxml2-dev libxslt1-dev"
+
+    run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
+    bashrc = <<-BASHRC
+if [ -d $HOME/.rbenv ]; then
+  export PATH="$HOME/.rbenv/bin:$PATH"
+  eval "$(rbenv init -)"
+fi
+BASHRC
+    put bashrc, "/tmp/rbenvrc"
+    run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
+    run "mv ~/.bashrc.tmp ~/.bashrc"
+    run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
+    run %q{eval "$(rbenv init -)"}
+  end
+  after "deploy:install", "rbenv:install"
+
+  desc "setup rbenv with ruby and bundler"
+  task :setup, roles: :web do
+    run "rbenv install #{ruby_version}"
+    run "rbenv global #{ruby_version}"
+    run "gem install bundler --no-ri --no-rdoc"
+    run "rbenv rehash"
+  end
+  after "deploy:setup", "rbenv:setup"
+end
config/recipes/rvm.rb
@@ -1,5 +1,4 @@
 require "rvm/capistrano"
-require 'bundler/capistrano'
 set :rvm_ruby_string, :local
 set :rvm_autolibs_flag, :enable
 set :rvm_type, :user
config/deploy.rb
@@ -1,6 +1,9 @@
-load "config/recipes/rvm"
+require 'bundler/capistrano'
+
 load "config/recipes/environments"
 load "config/recipes/base"
+#load "config/recipes/rvm"
+load "config/recipes/rbenv"
 load "config/recipes/nginx"
 load "config/recipes/unicorn"
 load "config/recipes/postgresql"
@@ -9,7 +12,6 @@ load "config/recipes/monit"
 
 set :application, "cakeside"
 set :user, "deployer"
-#set :group, "rvm"
 set :use_sudo, false
 default_run_options[:pty] = true # password prompt
 
Gemfile
@@ -65,3 +65,7 @@ group :production, :staging do
   gem 'newrelic_rpm'
   gem 'dalli'
 end
+
+group :staging do
+  gem 'unicorn'
+end
Gemfile.lock
@@ -145,6 +145,7 @@ GEM
     kaminari (0.14.1)
       actionpack (>= 3.0.0)
       activesupport (>= 3.0.0)
+    kgio (2.8.0)
     lol_dba (1.5.0)
       actionpack (>= 3.0)
       activerecord (>= 3.0)
@@ -193,6 +194,7 @@ GEM
       activesupport (= 4.0.0)
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
+    raindrops (0.11.0)
     rake (10.1.0)
     rdoc (3.12.2)
       json (~> 1.4)
@@ -260,6 +262,10 @@ GEM
     uglifier (2.1.2)
       execjs (>= 0.3.0)
       multi_json (~> 1.0, >= 1.0.2)
+    unicorn (4.6.3)
+      kgio (~> 2.6)
+      rack
+      raindrops (~> 0.7)
     uniform_notifier (1.2.0)
     warden (1.2.3)
       rack (>= 1.0)
@@ -317,3 +323,4 @@ DEPENDENCIES
   teaspoon
   turbolinks
   uglifier (>= 1.3.0)
+  unicorn