PageRenderTime 92ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/akshay-borade/kinecthub
Ruby | 93 lines | 47 code | 12 blank | 34 comment | 0 complexity | d51e2664ca38be0ae24916096ed4b335 MD5 | raw file
  1. require 'mina/rails'
  2. require 'mina/git'
  3. require 'mina/puma'
  4. # require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
  5. require 'mina/rvm' # for rvm support. (https://rvm.io)
  6. # Basic settings:
  7. # domain - The hostname to SSH to.
  8. # deploy_to - Path to deploy into.
  9. # repository - Git repo to clone from. (needed by mina/git)
  10. # branch - Branch name to deploy. (needed by mina/git)
  11. set :application_name, 'kinecthub'
  12. set :domain, 'ec2-13-232-155-114.ap-south-1.compute.amazonaws.com'
  13. set :deploy_to, '/var/www/kinect.com'
  14. set :repository, 'git@bitbucket.org:akshay-borade/kinecthub.git'
  15. set :branch, 'master'
  16. set :rails_env, 'production'
  17. set :identity_file, 'kinect.pem'
  18. # Optional settings:
  19. set :user, 'ubuntu' # Username in the server to SSH to.
  20. set :port, '22' # SSH port number.
  21. set :forward_agent, true # SSH forward_agent.
  22. # Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
  23. # Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more
  24. # run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files`
  25. # set :shared_dirs, fetch(:shared_dirs, []).push('public/assets')
  26. # set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')
  27. set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/assets')
  28. set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/puma.rb', 'config/application.yml', 'config/master.key')
  29. # This task is the environment that is loaded for all remote run commands, such as
  30. # `mina deploy` or `mina rake`.
  31. # set :puma_env, -> { fetch(:rails_env, 'staging') }
  32. # set :puma_env, -> { fetch(:rails_env, 'staging') }
  33. task :remote_environment do
  34. # If you're using rbenv, use this to load the rbenv environment.
  35. # Be sure to commit your .ruby-version or .rbenv-version to your repository.
  36. # invoke :'rbenv:load'
  37. # For those using RVM, use this to load an RVM version@gemset.
  38. invoke :'rvm:use', 'ruby-2.5.1@default'
  39. end
  40. # Put any custom commands you need to run at setup
  41. # All paths in `shared_dirs` and `shared_paths` will be created on their own.
  42. task :setup do
  43. # command %{rbenv install 2.3.0 --skip-existing}
  44. command %[touch "#{fetch(:shared_path)}/config/database.yml"]
  45. command %[touch "#{fetch(:shared_path)}/config/puma.rb"]
  46. command %[touch "#{fetch(:shared_path)}/config/application.yml"]
  47. command %[touch "#{fetch(:shared_path)}/config/master.key"]
  48. comment "Be sure to edit '#{fetch(:shared_path)}/config/database.yml', 'application.yml' and puma.rb."
  49. invoke :'rvm:use', 'ruby-2.5.1@default'
  50. end
  51. desc 'Deploys the current version to the server.'
  52. task :deploy do
  53. # uncomment this line to make sure you pushed your local branch to the remote origin
  54. # invoke :'git:ensure_pushed'
  55. deploy do
  56. # Put things that will set up an empty directory into a fully set-up
  57. # instance of your project.
  58. comment "Deploying #{fetch(:application_name)} to #{fetch(:domain)}:#{fetch(:deploy_to)}"
  59. invoke :'rvm:use', 'ruby-2.5.1@default'
  60. invoke :'git:clone'
  61. invoke :'deploy:link_shared_paths'
  62. invoke :'bundle:install'
  63. invoke :'rails:db_migrate'
  64. invoke :'rails:assets_precompile'
  65. invoke :'deploy:cleanup'
  66. on :launch do
  67. in_path(fetch(:current_path)) do
  68. invoke :'rvm:use', 'ruby-2.5.1@default'
  69. invoke :'puma:stop'
  70. invoke :'puma:start'
  71. # restart puma
  72. # invoke :'puma:phased_restart'
  73. end
  74. end
  75. end
  76. # you can use `run :local` to run tasks on local machine before of after the deploy scripts
  77. # run(:local){ say 'done' }
  78. end
  79. # For help in making your deploy script, see the Mina documentation:
  80. #
  81. # - https://github.com/mina-deploy/mina/tree/master/docs