Wordpress with Mina Automated Deployment Solution Jonathan Gravato DIG 4104c
What is Mina? • Ruby gem • Fast deployer and server automation tool • Creates Mina tasks (shell script) preset to • Create new directory • Make symbolic to common resources • Point public directory to new directory • Clean up old data • Uploads to server & executes from local • Requires • SSH connection • Git repository • Permission to change server config.
Alternatives • Capistrano • Remote server automation tool • Heavy on Ruby/Rails related features • Large learning curve • Capistrano • Vlad • Similar to Mina • Vlad the Deployer
What’s the difference? • Capistrano and Vlad • Each command run separately on their own SSH sessions • Mina • Entire procedure generated as remote run Bash script • Only one SSH session created for whole shell • Reduces SSH connection overhead Mina should be faster to deploy Requires less Ruby knowledge to implement.
Why Automated Deployment? • Saves time • Minimizes downtime during deployment • Reduces human mistakes • Missing files • Uploading wrong files • Shared between multiple developers in a team • Usually tied to source code control system
Why Automated Deployment? • Deploying with Git Hooks? • Git generates URL in reference to PHP script to perform tasks • Hole exposed due to URL • URL can be used to deploy files manually using PHP • Cleanup, roll back and lock cmds need to be created • All tasks handled in a simple Rake file tutorial link Mina task example
Case Study: Knights Capital • Lost $172,000+ per second for 45 minutes • 2700 seconds in 45 minutes • $465 million loss • Went bankrupt in 2012 due to failed deployment and cleanup procedures • New code deployed to 7 of 8 servers • New deploy did not remove old code • 8th server utilized old code • errors prompted warning messages to developers but were ignored • No one reviewed deployment records
Steps for Deploying with Mina • Prepare Server Layout • New three directory layout required for Mina (example) • Releases, Shared and Current directories created • Change Document Root to point to current directory • Location of symlink which references newest version and shared files • Install Mina • $ gem install mina • Setup Mina with Wordpress • Git repository with Wordpress source code • Generate config/deploy.rb shell script • Cleanup unnecessary lines of code • Configure server/login info • Configure Setup, Deploy and Rollback task
Steps for Deploying with Mina • SSH to server • Create new directory featuring your domain (root access) • Set ownership of new directory to user (vs server) • Create Mina directory structure on local machine • $ mina setup • Deploy current release (version) of code • Update code • Commit change • Push to repo • $ mina deploy • To roll back • $ mina rollback
Questions • What is Mina? • Deployer & server automation tool that uses a shell script to handle tasks. • What is a Rake file? • A rake file is the shell script which holds tasks or blocks of code to be run in Ruby. • What is one benefit to using automated deployment? Explain this benefit. • More secure • Saves time • Minimizes downtime • Reduces human mistakes