Mina is a remote server deployment tool similar to Capistrano. It uses Rake and queues up bash commands to execute them quickly on servers. It has a simpler configuration than Capistrano requiring only config/deploy.rb. Mina supports linking files and folders between servers and stages through plugins. Deployment involves running bundle, migrating databases, and precompiling assets before restarting apps.
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. 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.
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. 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. 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. Deploying
Ensure your web (apache, nginx) and app (unicorn,
puma, passenger) are configured.
mina setup
Create ~/shared/config/database.yml
mina deploy
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.