/config/deploy.rb
Ruby | 93 lines | 47 code | 12 blank | 34 comment | 0 complexity | d51e2664ca38be0ae24916096ed4b335 MD5 | raw file
- require 'mina/rails'
- require 'mina/git'
- require 'mina/puma'
- # require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
- require 'mina/rvm' # for rvm support. (https://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 :application_name, 'kinecthub'
- set :domain, 'ec2-13-232-155-114.ap-south-1.compute.amazonaws.com'
- set :deploy_to, '/var/www/kinect.com'
- set :repository, 'git@bitbucket.org:akshay-borade/kinecthub.git'
- set :branch, 'master'
- set :rails_env, 'production'
- set :identity_file, 'kinect.pem'
- # Optional settings:
- set :user, 'ubuntu' # Username in the server to SSH to.
- set :port, '22' # 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('public/assets')
- # set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')
- set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/assets')
- set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/puma.rb', 'config/application.yml', 'config/master.key')
- # This task is the environment that is loaded for all remote run commands, such as
- # `mina deploy` or `mina rake`.
- # set :puma_env, -> { fetch(:rails_env, 'staging') }
- # set :puma_env, -> { fetch(:rails_env, 'staging') }
- task :remote_environment do
- # If you're using rbenv, use this to load the rbenv environment.
- # Be sure to commit your .ruby-version or .rbenv-version to your repository.
- # invoke :'rbenv:load'
- # For those using RVM, use this to load an RVM version@gemset.
- invoke :'rvm:use', 'ruby-2.5.1@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
- # command %{rbenv install 2.3.0 --skip-existing}
- command %[touch "#{fetch(:shared_path)}/config/database.yml"]
- command %[touch "#{fetch(:shared_path)}/config/puma.rb"]
- command %[touch "#{fetch(:shared_path)}/config/application.yml"]
- command %[touch "#{fetch(:shared_path)}/config/master.key"]
- comment "Be sure to edit '#{fetch(:shared_path)}/config/database.yml', 'application.yml' and puma.rb."
- invoke :'rvm:use', 'ruby-2.5.1@default'
- end
- desc 'Deploys the current version to the server.'
- task :deploy do
- # uncomment this line to make sure you pushed your local branch to the remote origin
- # invoke :'git:ensure_pushed'
- deploy do
- # Put things that will set up an empty directory into a fully set-up
- # instance of your project.
- comment "Deploying #{fetch(:application_name)} to #{fetch(:domain)}:#{fetch(:deploy_to)}"
- invoke :'rvm:use', 'ruby-2.5.1@default'
- invoke :'git:clone'
- invoke :'deploy:link_shared_paths'
- invoke :'bundle:install'
- invoke :'rails:db_migrate'
- invoke :'rails:assets_precompile'
- invoke :'deploy:cleanup'
- on :launch do
- in_path(fetch(:current_path)) do
- invoke :'rvm:use', 'ruby-2.5.1@default'
- invoke :'puma:stop'
- invoke :'puma:start'
- # restart puma
- # invoke :'puma:phased_restart'
- end
- end
- end
- # you can use `run :local` to run tasks on local machine before of after the deploy scripts
- # run(:local){ say 'done' }
- end
- # For help in making your deploy script, see the Mina documentation:
- #
- # - https://github.com/mina-deploy/mina/tree/master/docs