require 'mina/bundler' require 'mina/rails' require 'mina/git' # require 'mina/rbenv' # for rbenv support. (http://rbenv.org) # 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) set :repository, ENV['GIT_REPOSITORY'] set :user, ENV['USERNAME'] set :port, ENV['PORT_NUMBER'] task :production do set :domain, ENV['PRODUCTION_DOMAIN'] set :deploy_to, ENV['PRODUCTION_DEPLOY_FOLDER'] set :branch, 'master' end task :staging do set :domain, ENV['STAGING_DOMAIN'] set :deploy_to, ENV['STAGING_DEPLOY_FOLDER'] set :branch, 'master' end # 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, ['log'] # Optional settings: # set :user, 'foobar' # Username in the server to SSH to. # set :port, '30000' # SSH port number. # set :forward_agent, true # SSH forward_agent. # This task is the environment that is loaded for most commands, such as # `mina deploy` or `mina rake`. task :environment do # If you're using rbenv, use this to load the rbenv environment. # Be sure to commit your .rbenv-version to your repository. # invoke :'rbenv:load' # For those using RVM, use this to load an RVM version@gemset. # invoke :'rvm:use[ruby-1.9.3-p125@default]' end # Put any custom mkdir's in here for when `mina setup` is ran. # For Rails apps, we'll make some of the shared paths that are shared between # all releases. task :setup => :environment do queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"] end desc "Deploys the current version to the server." task :deploy => :environment do deploy do to :prepare do queue! %[echo "-----> Stopping jobs"] queue! %[mkdir log] queue "RAILS_ENV=#{rails_env} #{deploy_to}/#{current_path}/bin/delayed_job stop" queue! %[rm -r log] end to :default do invoke :'git:clone' invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' invoke :'deploy:cleanup' end to :launch do queue %[echo "-----> Retarting jobs"] queue! %[mkdir -p #{deploy_to}/#{current_path}/tmp/pids] queue "RAILS_ENV=#{rails_env} #{deploy_to}/#{current_path}/bin/delayed_job restart" queue "mkdir -p #{deploy_to}/#{current_path}/tmp/" queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt" 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