diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..d04de11 --- /dev/null +++ b/Capfile @@ -0,0 +1,4 @@ +load 'deploy' if respond_to?(:namespace) # cap2 differentiator +Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } + +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 e03f53f..02a3217 100644 --- a/Gemfile +++ b/Gemfile @@ -43,4 +43,5 @@ group :development do gem "ruby-graphviz" gem "metric_fu" gem "tolk", :git => "git://github.com/cover/tolk.git" + gem "capistrano" end diff --git a/Gemfile.lock b/Gemfile.lock index f95a3b2..180cefd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,6 +49,12 @@ GEM babosa (0.3.5) bson_ext (1.3.1) builder (2.1.2) + capistrano (2.6.0) + highline + net-scp (>= 1.0.0) + net-sftp (>= 2.0.0) + net-ssh (>= 2.0.14) + net-ssh-gateway (>= 1.1.0) capybara (1.0.0) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -97,6 +103,7 @@ GEM babosa (~> 0.3.0) fssm (0.2.7) haml (3.1.2) + highline (1.6.2) hirb (0.4.5) hiredis (0.3.2) i18n (0.5.0) @@ -125,6 +132,13 @@ GEM syntax mime-types (1.16) mysql2 (0.2.11) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-sftp (2.0.5) + net-ssh (>= 2.0.9) + net-ssh (2.1.4) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) nifty-generators (0.4.6) nokogiri (1.4.6) polyglot (0.3.1) @@ -224,6 +238,7 @@ PLATFORMS DEPENDENCIES SystemTimer bson_ext + capistrano capybara (~> 1.0.0) compass database_cleaner diff --git a/README.rdoc b/README.rdoc index 323db40..658c841 100644 --- a/README.rdoc +++ b/README.rdoc @@ -108,3 +108,10 @@ On production server mysql database is used. Credentials are stored in non tracked file config/database.yml If you have problems with installing mysql2 gem, check this: http://stackoverflow.com/questions/3608287/installing-mysql2-gem-for-rails-3 If you don't have mysql database at all, you can bundle gems by: bundle install --without production + +Deployment is done by Capistrano +Deployment process: + +* make changes, commit and push to github server +* from your local machine, type: cap deploy +* That's all diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..5112717 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,49 @@ +require "bundler/capistrano" + +set :application, "peergroup" +set :user, "peergroup" +set :deploy_to, "/var/www/vhosts/kb.ihloff.de/htdocs/peergroup" + +set :domain, "s15395856.onlinehome-server.info" +set :rails_env, "production" + +role :app, domain +role :web, domain +role :db, domain, :primary => true + +set :scm, :git +set :repository, "git://github.com/wolfgangihloff/peergroup.git" +set :branch, "master" +set :deploy_via, :remote_cache +set :use_sudo, false + +# variables for bundler gem +set :bundle_without, [:development, :test] + +after "deploy:update_code", "deploy:link" +after "deploy", "deploy:cleanup" + +namespace :deploy do + task :default do + set :migrate_target, :latest + update_code + migrate + symlink + apache.restart + end + + task :restart, :roles => :app, :except => {:no_release => true} do + apache.restart + end + + task :link do + run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml" + run "ln -nfs #{shared_path}/config/redis.yml #{latest_release}/config/redis.yml" + end + + namespace :apache do + task :restart do + run "touch #{File.join(current_path, 'tmp', 'restart.txt')}" + end + end +end