Deploy Rails applications with Mina
Modern deployments require finesse. Long gone are the days of FTP file upload to server. These days we deploy version-controlled (GIT) code over SSH connections using automated systems. On Rails, Capistrano is a widely used deployment system, however, we at Creative opted for an up-and-coming alternative that is easily extendable (basically Rake) and real bloody fast
For Mina deployment you write what are essentially rake tasks which are then concatenated in one large Bash script automagically and executed over one SSH connection. This strategy is what makes Mina so fast. It also comes with built-in checks for need to migrate and compile assets, making most deployments last ~20s since migrations and asset precompilation can be skipped.
What Creative Mina deploy does
##### Standart deploy
- Pulls code from a GIT repo (master) branch
- Links the code to shared folder (public assets), links nginx etc.
- Conditionally migrates and precompiles
- Updates crontab
- Runs resque
- Phases puma server
- Built-in remote rake rask invocation with
- Rollback functionality
- Checks whether remote HEAD commit matches local one
- Control puma server and nginx
- Specify to which environment to deploy (production, staging)
The actual deploy.rb
desc "Deploys the current version to the server." task :deploy => :environment do |t, hash| if heads_match? deploy do invoke :'git:clone' invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:db_migrate' # ...