From c19d98a575451df64b1fe869a010635b195d0aac Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 16:10:09 +0100 Subject: [PATCH 01/17] capistrano deployment files. almost working? --- Capfile | 4 ++ Gemfile | 3 +- Gemfile.lock | 165 +++++++++++++++++++++++++++++++++++++++++++++++ config/deploy.rb | 36 +++++++++++ 4 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 Capfile create mode 100644 Gemfile.lock create mode 100644 config/deploy.rb diff --git a/Capfile b/Capfile new file mode 100644 index 000000000..6a798eb2b --- /dev/null +++ b/Capfile @@ -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 \ No newline at end of file diff --git a/Gemfile b/Gemfile index a17e08233..565c0bea6 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,8 @@ gem 'jquery-rails' # gem 'unicorn' # Deploy with Capistrano -# gem 'capistrano' +gem 'capistrano' +gem 'rvm-capistrano' # To use debugger # gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..6ae8f310c --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,165 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.8) + actionpack (= 3.2.8) + mail (~> 2.4.4) + actionpack (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.0) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.1.3) + activemodel (3.2.8) + activesupport (= 3.2.8) + builder (~> 3.0.0) + activerecord (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + activesupport (3.2.8) + i18n (~> 0.6) + multi_json (~> 1.0) + arel (3.0.2) + bcrypt-ruby (3.0.1) + builder (3.0.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) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.3.3) + devise (2.1.2) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) + diff-lcs (1.1.3) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + highline (1.6.14) + hike (1.2.1) + i18n (0.6.1) + journey (1.0.4) + jquery-rails (2.1.1) + railties (>= 3.1.0, < 5.0) + thor (~> 0.14) + json (1.7.5) + libv8 (3.3.10.4) + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + 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) + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.8) + actionmailer (= 3.2.8) + actionpack (= 3.2.8) + activerecord (= 3.2.8) + activeresource (= 3.2.8) + activesupport (= 3.2.8) + bundler (~> 1.0) + railties (= 3.2.8) + railties (3.2.8) + actionpack (= 3.2.8) + activesupport (= 3.2.8) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.3) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.2) + rspec-rails (2.11.0) + actionpack (>= 3.0) + 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) + sass (>= 3.1.10) + tilt (~> 1.3) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sqlite3 (1.3.6) + therubyracer (0.10.2) + libv8 (~> 3.3.10) + thor (0.16.0) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + uglifier (1.3.0) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + warden (1.2.1) + rack (>= 1.0) + webrat (0.7.3) + nokogiri (>= 1.2.0) + rack (>= 1.0) + rack-test (>= 0.5.3) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (>= 1.1.5) + capistrano + coffee-rails (~> 3.2.1) + devise + jquery-rails + rails (= 3.2.8) + rspec-rails + rvm-capistrano + sass-rails (~> 3.2.3) + sqlite3 + therubyracer + uglifier (>= 1.0.3) + webrat diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 000000000..53a514c24 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,36 @@ +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 + +# after "deploy", "deploy:bundle_gems" +# after "deploy:bundle_gems", "deploy:restart" + +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 From b4d5f75dae1b959460d0e412959828cd113b3fdd Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 16:23:23 +0100 Subject: [PATCH 02/17] added passenger gem for deployment --- Gemfile | 3 +++ Gemfile.lock | 8 ++++++++ config/deploy.rb | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 565c0bea6..ea6ee6bb2 100644 --- a/Gemfile +++ b/Gemfile @@ -49,3 +49,6 @@ gem 'devise' # for testing gem 'rspec-rails' gem 'webrat' + +# for phusion passenger (i.e. mod_rails) on the server +gem 'passenger' diff --git a/Gemfile.lock b/Gemfile.lock index 6ae8f310c..af1e6d53f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,7 @@ GEM coffee-script-source execjs coffee-script-source (1.3.3) + daemon_controller (1.0.0) devise (2.1.2) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -53,6 +54,7 @@ GEM erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) + fastthread (1.0.7) highline (1.6.14) hike (1.2.1) i18n (0.6.1) @@ -77,6 +79,11 @@ GEM 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) @@ -155,6 +162,7 @@ DEPENDENCIES coffee-rails (~> 3.2.1) devise jquery-rails + passenger rails (= 3.2.8) rspec-rails rvm-capistrano diff --git a/config/deploy.rb b/config/deploy.rb index 53a514c24..eecc95f9b 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,8 +1,8 @@ set :application, "dev.growstuff.org" -set :repository, "https://github.com/Growstuff/growstuff.git" +set :repository, "https://github.com/Skud/growstuff.git" set :scm, :git -set :branch, "dev" +set :branch, "story4deploy" set :user, "deploy" set :use_sudo, false set :deploy_to, "/var/www/#{application}" From d0c919acd5a4f4d8102cf31d224fca7f24303cb3 Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 16:47:40 +0100 Subject: [PATCH 03/17] attempting to get gemset working for deploy, see http://stackoverflow.com/questions/5680341/how-to-load-passenger-from-apache-with-rvm-and-unique-gem-sets --- config/setup_load_paths.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/setup_load_paths.rb diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb new file mode 100644 index 000000000..7f7852654 --- /dev/null +++ b/config/setup_load_paths.rb @@ -0,0 +1,17 @@ +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') + $LOAD_PATH.unshift rvm_lib_path + 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 + +ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__)) +require 'bundler/setup' + + From 02ce0e8ad06243538f2f2f9f5aa2036355693e19 Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 16:50:13 +0100 Subject: [PATCH 04/17] added .rvmrc as per http://stackoverflow.com/questions/5680341/how-to-load-passenger-from-apache-with-rvm-and-unique-gem-sets --- .rvmrc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .rvmrc diff --git a/.rvmrc b/.rvmrc new file mode 100644 index 000000000..51ac4685d --- /dev/null +++ b/.rvmrc @@ -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 [@], 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 From bb82b27cfaeda726381323ed2e6d2110432824bc Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 17:31:52 +0100 Subject: [PATCH 05/17] added rake to gemfile --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index ea6ee6bb2..fda3f89fc 100644 --- a/Gemfile +++ b/Gemfile @@ -52,3 +52,4 @@ gem 'webrat' # for phusion passenger (i.e. mod_rails) on the server gem 'passenger' +gem 'rake' From 45b4ef4dedd337e44e6aa7ac6ffb6f546577d9b1 Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 17:48:31 +0100 Subject: [PATCH 06/17] removing the setup_load_paths thing, at least temporarily, to see if this works any better. --- Gemfile.lock | 1 + config/deploy.rb | 3 --- config/setup_load_paths.rb | 17 ----------------- 3 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 config/setup_load_paths.rb diff --git a/Gemfile.lock b/Gemfile.lock index af1e6d53f..c872a0bf6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -164,6 +164,7 @@ DEPENDENCIES jquery-rails passenger rails (= 3.2.8) + rake rspec-rails rvm-capistrano sass-rails (~> 3.2.3) diff --git a/config/deploy.rb b/config/deploy.rb index eecc95f9b..4bdc3495d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -22,9 +22,6 @@ set :rvm_type, :user # if you're still using the script/reaper helper you will need # these http://github.com/rails/irs_process_scripts -# after "deploy", "deploy:bundle_gems" -# after "deploy:bundle_gems", "deploy:restart" - require 'bundler/capistrano' namespace :deploy do diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb deleted file mode 100644 index 7f7852654..000000000 --- a/config/setup_load_paths.rb +++ /dev/null @@ -1,17 +0,0 @@ -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') - $LOAD_PATH.unshift rvm_lib_path - 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 - -ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__)) -require 'bundler/setup' - - From 2255542af2b53777dd71cff7758c91d22651206e Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 17:56:59 +0100 Subject: [PATCH 07/17] re-added this config file --- config/setup_load_paths.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 config/setup_load_paths.rb diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb new file mode 100644 index 000000000..5ddf16903 --- /dev/null +++ b/config/setup_load_paths.rb @@ -0,0 +1,19 @@ +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') + $LOAD_PATH.unshift rvm_lib_path + 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' From 0d2630ae21129776d0445439836c3879fd285341 Mon Sep 17 00:00:00 2001 From: Skud Date: Thu, 6 Sep 2012 18:36:18 +0100 Subject: [PATCH 08/17] tweaked bundler flags/paths/etc --- config/deploy.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/deploy.rb b/config/deploy.rb index 4bdc3495d..f9ed78f44 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -22,6 +22,8 @@ set :rvm_type, :user # 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 From 75ca01188dce92d44a68e1de0af818e40ecaef2c Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 12 Sep 2012 09:23:49 +0100 Subject: [PATCH 09/17] commenting out 'unshift' line as recommended by error message from passenger' --- config/setup_load_paths.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index 5ddf16903..00d3acf10 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -2,7 +2,7 @@ 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') - $LOAD_PATH.unshift rvm_lib_path +# $LOAD_PATH.unshift rvm_lib_path require 'rvm' RVM.use_from_path! File.dirname(File.dirname(__FILE__)) rescue LoadError From bc9f6eea52a4a7303956a79ebf8281fe6c0e59b1 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 12 Sep 2012 09:41:30 +0100 Subject: [PATCH 10/17] added compass to gemfile --- Gemfile | 3 +++ Gemfile.lock | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index fda3f89fc..bf9d7c422 100644 --- a/Gemfile +++ b/Gemfile @@ -53,3 +53,6 @@ gem 'webrat' # for phusion passenger (i.e. mod_rails) on the server gem 'passenger' gem 'rake' + +# compile sass to css +gem 'compass' diff --git a/Gemfile.lock b/Gemfile.lock index c872a0bf6..f32a46d4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,7 @@ GEM 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) @@ -44,6 +45,10 @@ 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) @@ -55,6 +60,7 @@ GEM execjs (1.4.0) multi_json (~> 1.0) fastthread (1.0.7) + fssm (0.2.9) highline (1.6.14) hike (1.2.1) i18n (0.6.1) @@ -160,6 +166,7 @@ DEPENDENCIES bundler (>= 1.1.5) capistrano coffee-rails (~> 3.2.1) + compass devise jquery-rails passenger From e6c52527a724766eb04dfecb18df455a81aecdf2 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 12 Sep 2012 09:48:39 +0100 Subject: [PATCH 11/17] removing line i previously commented out at passenger's suggestion --- config/setup_load_paths.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/setup_load_paths.rb b/config/setup_load_paths.rb index 00d3acf10..7c6e7e133 100644 --- a/config/setup_load_paths.rb +++ b/config/setup_load_paths.rb @@ -2,7 +2,6 @@ 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') -# $LOAD_PATH.unshift rvm_lib_path require 'rvm' RVM.use_from_path! File.dirname(File.dirname(__FILE__)) rescue LoadError From 4045b676f8997bd6567e498861691bfcf8e2f58a Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 12 Sep 2012 09:52:03 +0100 Subject: [PATCH 12/17] tweaked capistrano config to point to the actual dev branch --- config/deploy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index f9ed78f44..81d30e69a 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,8 +1,8 @@ set :application, "dev.growstuff.org" -set :repository, "https://github.com/Skud/growstuff.git" +set :repository, "https://github.com/Growstuff/growstuff.git" set :scm, :git -set :branch, "story4deploy" +set :branch, "dev" set :user, "deploy" set :use_sudo, false set :deploy_to, "/var/www/#{application}" From 0d5a879c4effe921beb591e1e6e078da26d7a5cd Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 15 Sep 2012 09:50:58 +0100 Subject: [PATCH 13/17] compile assets (css etc) in production (i.e. dev) as per http://stackoverflow.com/questions/7275636/rails-3-1-0-actionviewtemplateerrror-application-css-isnt-precompiled --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 03476e4d4..811d04ae7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 From 4fa0eda475e81aa51142533a9532710380c824dc Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 15 Sep 2012 09:54:16 +0100 Subject: [PATCH 14/17] go back to deploying this branch (not dev) for testing --- config/deploy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 81d30e69a..f9ed78f44 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,8 +1,8 @@ set :application, "dev.growstuff.org" -set :repository, "https://github.com/Growstuff/growstuff.git" +set :repository, "https://github.com/Skud/growstuff.git" set :scm, :git -set :branch, "dev" +set :branch, "story4deploy" set :user, "deploy" set :use_sudo, false set :deploy_to, "/var/www/#{application}" From e2751a488c61150bc2780f3ed209fadfd359fa88 Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 15 Sep 2012 10:22:51 +0100 Subject: [PATCH 15/17] using cape to run rake tasks on dev server --- Gemfile | 1 + Gemfile.lock | 2 ++ config/deploy.rb | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/Gemfile b/Gemfile index bf9d7c422..814f5b8fe 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ gem 'webrat' # for phusion passenger (i.e. mod_rails) on the server gem 'passenger' gem 'rake' +gem 'cape' # compile sass to css gem 'compass' diff --git a/Gemfile.lock b/Gemfile.lock index f32a46d4b..6a1567a1e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,7 @@ GEM arel (3.0.2) bcrypt-ruby (3.0.1) builder (3.0.0) + cape (1.4.0) capistrano (2.13.3) highline net-scp (>= 1.0.0) @@ -164,6 +165,7 @@ PLATFORMS DEPENDENCIES bundler (>= 1.1.5) + cape capistrano coffee-rails (~> 3.2.1) compass diff --git a/config/deploy.rb b/config/deploy.rb index f9ed78f44..fe386ec2e 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -33,3 +33,17 @@ namespace :deploy 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:migrate', :roles => :app do |env| + env['RAILS_ENV'] = rails_env + end +end From 8c8c796bc5d81abc0a97d49b1b4b91c7194250b4 Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 15 Sep 2012 10:43:17 +0100 Subject: [PATCH 16/17] deploy now seems to be working --- config/deploy.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index fe386ec2e..ab45b1993 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,8 +1,8 @@ set :application, "dev.growstuff.org" -set :repository, "https://github.com/Skud/growstuff.git" +set :repository, "https://github.com/Growstuff/growstuff.git" set :scm, :git -set :branch, "story4deploy" +set :branch, "dev" set :user, "deploy" set :use_sudo, false set :deploy_to, "/var/www/#{application}" @@ -42,7 +42,9 @@ 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 From bc010f8e41387a80fc78316b9bad549221cb15db Mon Sep 17 00:00:00 2001 From: Skud Date: Sat, 15 Sep 2012 10:47:21 +0100 Subject: [PATCH 17/17] migrate db after deploying --- config/deploy.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/deploy.rb b/config/deploy.rb index ab45b1993..e69edc538 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -49,3 +49,5 @@ Cape do env['RAILS_ENV'] = rails_env end end + +after :deploy, 'db:migrate'