deploy
This commit is contained in:
parent
1a019c1f08
commit
769756176a
4
Capfile
Normal file
4
Capfile
Normal file
@ -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
|
109
config/deploy.rb
Normal file
109
config/deploy.rb
Normal file
@ -0,0 +1,109 @@
|
||||
set :application, 'site_perso_app'
|
||||
set :domain, 'new.nicolasbally.com'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require "rvm/capistrano"
|
||||
|
||||
set :rvm_ruby_string, 'ruby-1.9.3-p0'
|
||||
set :rvm_type, :user
|
||||
|
||||
set :user, 'web'
|
||||
|
||||
|
||||
|
||||
set :deploy_to, "/home/#{user}/#{application}/"
|
||||
set :deploy_via, :remote_cache
|
||||
|
||||
set :normalize_asset_timestamps, false
|
||||
|
||||
|
||||
set :rails_env, "production"
|
||||
|
||||
|
||||
|
||||
role :app, domain
|
||||
role :web, domain
|
||||
role :db, domain, :primary => true
|
||||
|
||||
set :scm, :git
|
||||
set :repository, "git@gitlab.bally.me:root/site-perso.git"
|
||||
set :branch, "master"
|
||||
|
||||
default_run_options[:pty] = true
|
||||
|
||||
|
||||
|
||||
before "deploy:symlink", "deploy:bundle_gems"
|
||||
after "deploy:bundle_gems", "deploy:make_simlinks"
|
||||
after "deploy:make_simlinks", "assets:precompile"
|
||||
|
||||
|
||||
|
||||
# after "deploy", "deploy:restart"
|
||||
after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
|
||||
#after "deploy", "deploy:bundle_gems"
|
||||
#after "deploy:bundle_gems", "deploy:make_simlinks"
|
||||
#after "deploy:make_simlinks", "assets:precompile"
|
||||
#after "assets:precompile", "deploy:restart"
|
||||
#after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
|
||||
namespace :assets do
|
||||
task :precompile, :roles => :web do
|
||||
run "rm -rf #{release_path}/public/assets"
|
||||
run "ln -s #{deploy_to}shared/assets #{release_path}/public/assets"
|
||||
|
||||
|
||||
run "cd #{release_path} && bundle exec rake assets:precompile --trace"
|
||||
end
|
||||
|
||||
task :cleanup, :roles => :web do
|
||||
run "cd #{current_path} && RAILS_ENV=production bundle exec rake assets:clean"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace :deploy do
|
||||
task :bundle_gems do
|
||||
run "cd #{release_path} && bundle install"
|
||||
end
|
||||
|
||||
task :make_simlinks do
|
||||
run "rm -rf #{release_path}/private_medias"
|
||||
run "ln -s #{deploy_to}shared/storage/private #{release_path}/private_medias"
|
||||
run "rm -rf #{release_path}/public/public_medias"
|
||||
run "ln -s #{deploy_to}shared/storage/public #{release_path}/public/public_medias"
|
||||
|
||||
run "rm -rf #{release_path}/db/production.sqlite3"
|
||||
run "ln -s #{deploy_to}shared/production.sqlite3 #{release_path}/db/production.sqlite3"
|
||||
end
|
||||
|
||||
task :start do
|
||||
sudo "service #{application} start"
|
||||
end
|
||||
task :stop do
|
||||
run "service #{application} stop"
|
||||
end
|
||||
task :restart, :roles => :app, :except => { :no_release => true } do
|
||||
sudo "service #{application} restart"
|
||||
end
|
||||
task :migrate do
|
||||
run "cd #{deploy_to}current && rake db:migrate RAILS_ENV=#{rails_env}"
|
||||
|
||||
end
|
||||
|
||||
task :seeds do
|
||||
run "cd #{deploy_to}current && rake db:seeds RAILS_ENV=#{rails_env}"
|
||||
|
||||
end
|
||||
end
|
||||
|
21
config/nginx.conf
Normal file
21
config/nginx.conf
Normal file
@ -0,0 +1,21 @@
|
||||
upstream site_perso_app_unicorn {
|
||||
server unix:/home/web/site_perso_app/shared/tmp/unicorn.sock fail_timeout=0;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name new.nicolasbally.com;
|
||||
root /home/web/site_perso_app/current/public;
|
||||
try_files $uri/index.html $uri @unicorn;
|
||||
|
||||
location @unicorn {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
proxy_pass http://site_perso_app_unicorn;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /500.html;
|
||||
client_max_body_size 4G;
|
||||
keepalive_timeout 10;
|
||||
}
|
10
config/unicorn.rb
Normal file
10
config/unicorn.rb
Normal file
@ -0,0 +1,10 @@
|
||||
@rails_app = "site_perso_app"
|
||||
|
||||
working_directory "/home/web/#{@rails_app}/current"
|
||||
pid "/home/web/#{@rails_app}/shared/unicorn.pid"
|
||||
stderr_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
|
||||
stdout_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
|
||||
|
||||
listen "/home/web/#{@rails_app}/shared/tmp/unicorn.sock"
|
||||
worker_processes 2
|
||||
timeout 30
|
Loading…
x
Reference in New Issue
Block a user