PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/brucemakallan/uganda-swimming-federation
Ruby | 92 lines | 54 code | 12 blank | 26 comment | 0 complexity | 680d35cc568ef2d8bd0dbae1bafa1804 MD5 | raw file
  1. require 'mina/rails'
  2. require 'mina/git'
  3. require 'mina/rvm'
  4. # Basic settings:
  5. # domain - The hostname to SSH to.
  6. # deploy_to - Path to deploy into.
  7. # repository - Git repo to clone from. (needed by mina/git)
  8. # branch - Branch name to deploy. (needed by mina/git)
  9. set :application_name, 'ugandaswimming'
  10. set :domain, '51.15.226.183'
  11. set :user, fetch(:application_name)
  12. set :deploy_to, "/home/#{fetch(:user)}/app"
  13. set :repository, 'https://brucemakallan@bitbucket.org/brucemakallan/uganda-swimming-federation.git'
  14. set :branch, 'master'
  15. set :rvm_use_path, '/etc/profile.d/rvm.sh'
  16. # Optional settings:
  17. # set :user, 'foobar' # Username in the server to SSH to.
  18. # set :port, '30000' # SSH port number.
  19. # set :forward_agent, true # SSH forward_agent.
  20. # Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
  21. # Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more
  22. # run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files`
  23. # set :shared_dirs, fetch(:shared_dirs, []).push('public/assets')
  24. set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')
  25. # This task is the environment that is loaded for all remote run commands, such as
  26. # `mina deploy` or `mina rake`.
  27. task :remote_environment do
  28. ruby_version = "2.4.0"
  29. raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
  30. invoke :'rvm:use', ruby_version
  31. end
  32. # Put any custom commands you need to run at setup
  33. # All paths in `shared_dirs` and `shared_paths` will be created on their own.
  34. task :setup do
  35. in_path(fetch(:shared_path)) do
  36. command %[mkdir -p config]
  37. # Create database.yml for Postgres if it doesn't exist
  38. path_database_yml = "config/database.yml"
  39. database_yml = %[production:
  40. database: Uganda-Swimming-Federation_production
  41. adapter: postgresql
  42. pool: 5
  43. timeout: 5000]
  44. command %[test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml}]
  45. # Create secrets.yml if it doesn't exist
  46. path_secrets_yml = "config/secrets.yml"
  47. secrets_yml = %[production:\n secret_key_base:\n #{`bundle exec rake secret`.strip}]
  48. command %[test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml}]
  49. # Remove others-permission for config directory
  50. command %[chmod -R o-rwx config]
  51. end
  52. end
  53. desc "Deploys the current version to the server."
  54. task :deploy do
  55. # uncomment this line to make sure you pushed your local branch to the remote origin
  56. # invoke :'git:ensure_pushed'
  57. deploy do
  58. # Put things that will set up an empty directory into a fully set-up
  59. # instance of your project.
  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. command "sudo service #{fetch(:user)} restart"
  68. end
  69. end
  70. # you can use `run :local` to run tasks on local machine before of after the deploy scripts
  71. # run(:local){ say 'done' }
  72. end
  73. # For help in making your deploy script, see the Mina documentation:
  74. #
  75. # - https://github.com/mina-deploy/mina/tree/master/docs