# frozen_string_literal: true require "mina/rails" require "mina/git" require "mina/rvm" # for rvm support. (https://rvm.io) require_relative "./git_config.rb" require_relative "./predeploy.rb" require_relative "./tasks.rb" def load_project invoke :before_run unless fetch(:project) end # 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 :application_name, 'foobar' # set :domain, 'foobar.com' # set :deploy_to, '/var/www/foobar.com' # set :repository, 'git://...' # set :branch, 'master' # 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. # Shared dirs and files will be symlinked into the app-folder by the # 'deploy:link_shared_paths' step. Some plugins already add folders to # shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many # more run `mina -d` to see all folders and files already included in # `shared_dirs` and `shared_files` set :shared_dirs, fetch(:shared_dirs, []).push( "log", "tmp/pids", "tmp/cache", "tmp/sockets", "bundle", "public/system" ) set :shared_files, fetch(:shared_files, []).push( "config/database.yml", "config/secrets.yml" ) # This task is the environment that is loaded for all remote run commands, such # as `mina deploy` or `mina rake`. task :environment do # Be sure to commit your .ruby-version to your repository. # 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 commands you need to run at setup # All paths in `shared_dirs` and `shared_paths` will be created on their own. task :setup do end task :staging do set :stage, :staging set :rails_env, "staging" end task :production do set :stage, :production set :rails_env, "production" end if ENV["stage"] == "production" invoke :production else invoke :staging end desc "Run predeployment tasks." task predeploy: :remote_environment do load_project run :remote do invoke :setup end invoke :'deploy_configure:create_configs' invoke :'deploy_prepare:create_vhost' invoke :'deploy_prepare:configure_pg' invoke :'deploy_prepare:set_owner' end desc "Deploys the current version to the server." task deploy: :remote_environment do load_project deploy do # Put things that will set up an empty directory into a fully set-up # instance of your project. invoke :rvm_use invoke :checkout_release invoke :link_shared_dirs invoke :'bundle:install' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' invoke :'deploy:cleanup' on :launch do invoke :restart end end invoke :open_browser end