From 460f763be53fb5ab3cab26bd81a3e04b31fb45f3 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 7 Jul 2014 16:08:53 +0200 Subject: [PATCH] Add Mina configuration --- Gemfile | 2 ++ Gemfile.lock | 5 ++++ config/deploy.rb | 48 ++++++++++++++++++++++++------- config/environments/production.rb | 2 +- config/routes.rb | 3 +- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index f9f742c0..7be7e60f 100644 --- a/Gemfile +++ b/Gemfile @@ -111,6 +111,8 @@ group :development do gem 'sqlite3' # Use letter_opener to open mails in development gem 'letter_opener' + # mina is a blazing fast deployment system + gem 'mina' end # Use rspec and capybara as testing framework diff --git a/Gemfile.lock b/Gemfile.lock index 02a4e990..25463510 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,6 +177,9 @@ GEM treetop (~> 1.4.8) method_source (0.8.2) mime-types (1.25.1) + mina (0.3.0) + open4 + rake mini_portile (0.6.0) minitest (5.3.5) multi_json (1.10.1) @@ -208,6 +211,7 @@ GEM omniauth-openid (1.0.1) omniauth (~> 1.0) rack-openid (~> 1.3.1) + open4 (1.3.3) orm_adapter (0.5.0) paper_trail (3.0.1) activerecord (>= 3.0, < 5.0) @@ -409,6 +413,7 @@ DEPENDENCIES jquery-rails jquery-ui-rails letter_opener + mina mysql2 omniauth omniauth-facebook diff --git a/config/deploy.rb b/config/deploy.rb index f3f702f9..9a2ee2f2 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,16 +1,42 @@ -namespace :paperclip do +require 'mina/bundler' +require 'mina/rails' +require 'mina/git' - desc "Create a storage folder for Paperclip attachment in shared path" - task :create_storage do - run "mkdir -p #{shared_path}/storage" - end +set :domain, 'proxy-opensuse.suse.de' +set :port, 2214 +set :user, 'osem' +set :deploy_to, '/srv/www/vhosts/opensuse.org/events' +set :repository, 'https://github.com/openSUSE/osem.git' - desc "Link the Paperclip storage folder into the current release" - task :link_storage do - run "ln -nfs #{shared_path}/storage #{release_path}/storage" - end +# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. +# They will be linked in the 'deploy:link_shared_paths' step. +set :shared_paths, %w{ config/database.yml log public/system config/secrets.yml config/config.yml tmp} +task :setup => :environment do + queue! %[mkdir -p "#{deploy_to}/shared/log"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] + + queue! %[mkdir -p "#{deploy_to}/shared/config"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"] + + queue! %[touch "#{deploy_to}/shared/config/database.yml"] + + queue! %[touch "#{deploy_to}/shared/system"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/system"] + queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."] end -before "deploy:setup", 'paperclip:create_storage' -after "deploy:update_code", "paperclip:link_storage" +desc 'Deploys the current version to the server.' +task :deploy => :environment do + deploy do + invoke :'git:clone' + invoke :'deploy:link_shared_paths' + invoke :'bundle:install' + invoke :'rails:db_migrate' + invoke :'rails:assets_precompile' + + to :launch do + queue "touch #{deploy_to}/tmp/restart.txt" + end + end +end diff --git a/config/environments/production.rb b/config/environments/production.rb index 2a2254f1..f7cccb68 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -29,7 +29,7 @@ Osem::Application.configure do # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. diff --git a/config/routes.rb b/config/routes.rb index 41cd31e8..1e07e8a0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,5 +114,6 @@ Osem::Application.routes.draw do get "/admin" => redirect("/admin/conference") - root :to => "home#index" + root :to => "home#index", :via => [:get, :options] + end