Mina deployment

883 views

Published on

Learn how to use Mina to easily deploy Ruby on Rails. Understand its strengths and weaknesses when compared to Capistrano.

Published in: Software
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
883
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
3
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Mina deployment

  1. 1. Mina Deployment Creston Jamison RubyTree Software, Inc.
  2. 2. What is Mina?  A remote server build and run tool.  VERY similar to Capistrano.  Uses Rake (with a little “sugar”).  Queues up bash commands and then sends and executes them on servers.  This makes it very fast.
  3. 3. Details  In general, simpler to use than Capistrano.  Only need to configure config/deploy.rb  Multi-Stage offered by mina-stage plugin  Easily sym link files and folders (e.g., config/database.yml, log)  Same basic directory structure as Capistrano.  Does not support parallelism & multi-server.
  4. 4. Gemfile group :development do gem ‘mina' end
  5. 5. Run bundle bundle exec mina init  Setup public key authentication to log in as deploy_user.
  6. 6. config/deploy.rb 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)
  7. 7. config/deploy.rb, part 2 set :domain, ‘www.deploy_mina.com' set :deploy_to, ‘/var/www/www.deploy_mina.com' set :repository, 'git@github.com:acct/deploy_mina.git' set :branch, 'master' set :shared_paths, ['config/database.yml', 'log', 'tmp/pids'] # Optional settings: set :user, ‘deploy_user' # Username in the server to SSH to. set :port, ‘30000' # SSH port number. set :forward_agent, true
  8. 8. config/deploy.rb, part 3 task :setup => :environment do queue! %[mkdir -p "#{deploy_to}/shared/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] queue! %[mkdir -p "#{deploy_to}/shared/config"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"] queue! %[touch "#{deploy_to}/shared/config/database.yml"] queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."] end
  9. 9. config/deploy.rb, part 4 task :deploy => :environment do deploy do invoke :'git:clone' invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' to :launch do queue "/etc/init.d/unicorn_deploy_mina restart" end end end
  10. 10. Deploying  Ensure your web (apache, nginx) and app (unicorn, puma, passenger) are configured.  mina setup  Create ~/shared/config/database.yml  mina deploy
  11. 11. Conclusion  Easier to implement and understand than Capistrano (with better documentation).  Faster than Capistrano.  Great for single server deployments.  For multi-stage or multiple environments, you can use variables or the mina-stage plugin.  Not as active as Capistrano. It is on version 0.3.0 whereas Capistrano is at version 3.2.1.
  12. 12. References http://nadarei.co/mina/ https://github.com/mina-deploy/mina https://github.com/endoze/mina-multistage
  13. 13. Questions? Creston Jamison @crestonjamison creston.jamison@rubytreesoftware.com

×