The sturdy d'ploy-mate

T'arrust me, bucko. I can do it.
This little gem can be added to your ruby-projects in order to set up a working ruby-server and deploy to it.
The resulting server will work with this setup:
- NGINX Webserver (http://nginx.org/)
- Unicorn Rack App Server (http://unicorn.bogomips.org/)
- Bluepill Process Monitoring (https://github.com/bluepill-rb/bluepill)
- RVM as user-install (http://rvm.io)
- [Optional] ImageMagick (http://www.imagemagick.org)
Other stuff taken care of:
- Logration
- Automatic updates
- NTP
You can choose a Database-Engine:
- MySQL
- Postgres
If you are not using Amazon AWS as a host: The GEM needs a working Amazon AWS-style ubuntu-user on the system in order to work properly. It will create one, if needed.
It uses the following Capistrano-roles to divide the installed components:
- web: Machines with this role run NGINX as proxy
- app: Machines with this role run the Ruby-webapp
- search: [OPTIONAL] Machines with this role run ElasticSearch
- cronjobs: [OPTIONAL] For environments where
whenevershould manage/run cronjobs
Changelog
- 2015-08-06: Support for optional Sidekiq
- 2015-06-23: Support for optional ElasticSearch
- 2015-06-23: Support for optional
whenever - 2015-06-23: Support for optional
imagemagick - 2015-06-23: Support creation of working
ubuntuuser. Error out if another user thanubuntuis used. - 2015-06-22: Support for choosing your Ruby-version when creating the
Capfile. Suggestions come from.ruby-versionandGemfile. - 2015-04-29: Load custom rake tasks from lib/capistrano/tasks directory.
You need to run the generator
rake deploy_mate:installagain or addDir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }to your Capfile.
Installation
Add this to your project's Gemfile:
gem 'deploy_mate'
and run bundle install.
After installing the gem you need to generate the files needed to be able to deploy with capistrano.
Add this at the end of your project's Rakefile:
load 'deploy_mate/tasks.rake'
then run
rake deploy_mate:install
Follow the instructions.
This will create the following files for you:
Capfile
config/deploy.rb
config/deploy/<your-stage>.rb
When done: Remove load 'deploy_mate/tasks.rake' from your Rakefile. It is not needed anymore and will otherwise only cause problems.
Updating the gem
Should you need to update your deploy_mate-version (e.g. because somebody fixed a bug in the gem), run:
bundle update deploy_mate
This will bump you up to the latest repo-version.
Setting up a server
- Spawn yourself a basic Ubuntu 14 at the provider of your choice.
- Create a working SSH-configuration for that server and try it our using
ssh <your-server-name> - Run
cap <your-stage> machine:initto install the needed packages. - Run
cap <your-stage> machine:setupthe setup all needed configuration-files on the server - Run
cap <your-stage> deployand be done.