2015-09-01 14:42:53 +02:00
|
|
|
require 'mina/bundler'
|
|
|
|
require 'mina/rails'
|
|
|
|
require 'mina/git'
|
2016-02-24 11:12:18 +01:00
|
|
|
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
|
2015-09-01 14:42:53 +02:00
|
|
|
# require 'mina/rvm' # for rvm support. (http://rvm.io)
|
|
|
|
|
|
|
|
# Basic settings:
|
|
|
|
# domain - The hostname to SSH to.
|
|
|
|
# deploy_to - Path to deploy into.
|
|
|
|
# repository - Git repo to clone from. (needed by mina/git)
|
|
|
|
# branch - Branch name to deploy. (needed by mina/git)
|
|
|
|
|
|
|
|
ENV['to'] ||= "staging"
|
2016-10-10 18:21:46 +02:00
|
|
|
ENV['to'] = "staging" unless ["staging", "production", "opensimplif"].include?(ENV['to'])
|
2015-09-01 14:42:53 +02:00
|
|
|
|
|
|
|
raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['domain'].nil?
|
|
|
|
|
|
|
|
print "Deploy to #{ENV['to']} environment branch #{branch}\n"
|
|
|
|
|
|
|
|
# set :domain, '5.135.190.60'
|
|
|
|
set :domain, ENV['domain']
|
2016-02-24 11:12:18 +01:00
|
|
|
set :repository, 'https://github.com/sgmap/tps.git'
|
2015-09-01 14:42:53 +02:00
|
|
|
set :port, 2200
|
|
|
|
|
|
|
|
set :deploy_to, '/var/www/tps_dev'
|
|
|
|
|
|
|
|
if ENV["to"] == "staging"
|
|
|
|
if ENV['branch'].nil?
|
|
|
|
set :branch, 'staging'
|
|
|
|
else
|
|
|
|
set :branch, ENV['branch']
|
|
|
|
end
|
|
|
|
set :deploy_to, '/var/www/tps_dev'
|
2016-02-24 11:12:18 +01:00
|
|
|
set :user, 'tps_dev' # Username in the server to SSH to.
|
2015-09-01 14:42:53 +02:00
|
|
|
appname = 'tps_dev'
|
|
|
|
elsif ENV["to"] == "production"
|
|
|
|
if ENV['branch'].nil?
|
|
|
|
set :branch, 'master'
|
|
|
|
else
|
|
|
|
set :branch, ENV['branch']
|
|
|
|
end
|
|
|
|
set :deploy_to, '/var/www/tps'
|
2016-02-24 11:12:18 +01:00
|
|
|
set :user, 'tps' # Username in the server to SSH to.
|
2015-09-01 14:42:53 +02:00
|
|
|
appname = 'tps'
|
2016-10-10 18:21:46 +02:00
|
|
|
elsif ENV["to"] == "opensimplif"
|
|
|
|
if ENV['branch'].nil?
|
|
|
|
set :branch, 'master'
|
|
|
|
else
|
|
|
|
set :branch, ENV['branch']
|
|
|
|
end
|
|
|
|
set :deploy_to, '/var/www/opensimplif'
|
|
|
|
set :user, 'opensimplif' # Username in the server to SSH to.
|
|
|
|
appname = 'opensimplif'
|
2015-09-01 14:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
set :rails_env, ENV["to"]
|
2016-10-10 18:21:46 +02:00
|
|
|
|
|
|
|
if ENV["to"] == "opensimplif"
|
|
|
|
set :rails_env, "production"
|
|
|
|
end
|
|
|
|
|
2015-09-01 14:42:53 +02:00
|
|
|
# For system-wide RVM install.
|
|
|
|
# set :rvm_path, '/usr/local/rvm/bin/rvm'
|
|
|
|
|
|
|
|
# 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, [
|
2016-02-24 11:12:18 +01:00
|
|
|
'log',
|
|
|
|
'bin',
|
|
|
|
'uploads',
|
|
|
|
'tmp/pids',
|
|
|
|
'tmp/cache',
|
|
|
|
'tmp/sockets',
|
|
|
|
'public/system',
|
|
|
|
'public/uploads',
|
|
|
|
'config/database.yml',
|
2016-06-07 10:31:54 +02:00
|
|
|
"config/fog_credentials.yml",
|
2016-02-24 11:12:18 +01:00
|
|
|
'config/initializers/secret_token.rb',
|
2016-07-01 14:45:07 +02:00
|
|
|
'config/initializers/features.yml',
|
2016-10-10 18:21:46 +02:00
|
|
|
"config/environments/#{rails_env}.rb",
|
2016-02-24 11:12:18 +01:00
|
|
|
"config/initializers/token.rb",
|
2016-09-01 12:09:44 +02:00
|
|
|
"config/initializers/urls.rb",
|
2016-02-24 11:12:18 +01:00
|
|
|
"config/initializers/super_admin.rb",
|
|
|
|
"config/unicorn.rb",
|
|
|
|
"config/initializers/raven.rb",
|
|
|
|
'config/france_connect.yml',
|
2016-07-05 11:50:45 +02:00
|
|
|
'config/initializers/mailjet.rb',
|
2016-10-10 18:21:46 +02:00
|
|
|
'config/initializers/storage_url.rb',
|
|
|
|
'app/views/root/landing.html.haml'
|
2016-02-24 11:12:18 +01:00
|
|
|
]
|
2015-09-01 14:42:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
set :rbenv_path, "/usr/local/rbenv/bin/rbenv"
|
|
|
|
|
|
|
|
# Optional settings:
|
|
|
|
# set :user, 'foobar' # Username in the server to SSH to.
|
|
|
|
# set :port, '30000' # SSH port number.
|
2016-02-24 11:12:18 +01:00
|
|
|
set :forward_agent, true # SSH forward_agent.
|
2015-09-01 14:42:53 +02:00
|
|
|
|
|
|
|
# This task is the environment that is loaded for most commands, such as
|
|
|
|
# `mina deploy` or `mina rake`.
|
|
|
|
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/bin"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/bin"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/tmp/pids"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/pids"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/tmp/cache"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/cache"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/tmp/sockets"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp/sockets"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/public/system"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/public/system"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/public/uploads"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/public/uploads"]
|
|
|
|
|
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/config"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
|
|
|
|
|
2016-10-10 18:21:46 +02:00
|
|
|
queue! %[mkdir -p "#{deploy_to}/shared/app"]
|
|
|
|
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/app"]
|
|
|
|
|
2015-09-01 14:42:53 +02:00
|
|
|
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
|
2016-02-24 11:12:18 +01:00
|
|
|
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
|
2015-09-01 14:42:53 +02:00
|
|
|
|
|
|
|
queue! %[touch "#{deploy_to}/shared/environments/production.rb"]
|
2016-02-24 11:12:18 +01:00
|
|
|
queue %[echo "-----> Be sure to edit 'shared/environments/production.rb'."]
|
2015-09-01 14:42:53 +02:00
|
|
|
|
|
|
|
queue! %[touch "#{deploy_to}/shared/environments/staging.rb"]
|
2016-02-24 11:12:18 +01:00
|
|
|
queue %[echo "-----> Be sure to edit 'shared/environments/staging.rb'."]
|
2015-09-01 14:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Deploys the current version to the server."
|
|
|
|
task :deploy => :environment do
|
|
|
|
queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims'
|
|
|
|
deploy do
|
|
|
|
# Put things that will set up an empty directory into a fully set-up
|
|
|
|
# instance of your project.
|
|
|
|
invoke :'git:clone'
|
|
|
|
invoke :'deploy:link_shared_paths'
|
|
|
|
invoke :'bundle:install'
|
|
|
|
invoke :'rails:db_migrate'
|
|
|
|
invoke :'rails:assets_precompile'
|
|
|
|
|
|
|
|
to :launch do
|
|
|
|
queue "/etc/init.d/#{user} upgrade "
|
2016-06-07 10:31:54 +02:00
|
|
|
|
2016-02-24 11:12:18 +01:00
|
|
|
queue "cd #{deploy_to}/#{current_path}/"
|
|
|
|
queue "bundle exec rake db:seed RAILS_ENV=#{rails_env}"
|
|
|
|
queue %[echo "-----> Rake Seeding Completed."]
|
2015-09-01 14:42:53 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# For help in making your deploy script, see the Mina documentation:
|
|
|
|
#
|
|
|
|
# - http://nadarei.co/mina
|
|
|
|
# - http://nadarei.co/mina/tasks
|
|
|
|
# - http://nadarei.co/mina/settings
|
|
|
|
# - http://nadarei.co/mina/helpers
|