Negroku is an opinionated collection of recipes for capistrano.
The goal is to be able to deploy ruby applications without the hassle of configure and define all the stuff involved in an application deployment.
Install negroku as a global gem.
$ gem install negroku --pre
Add the negroku gem to your
Gemfile development group to lock the version your are going to use.
group :development do gem 'negroku', '~> 2.0.0.pre3' end
$ bundle install
Prepare your application
Create your app executing the following command, and just follow the on-screen questions.
$ negroku app create
Give your application a name
This will be used to create the app folder structure in the server.
Please choose your repository url
You'll need to choose the git respository where your are going deploy your project from. Typically a GitHub repository.
If you have already initializated your git repository for the project, you'll be offered to choose the remotes of the current repo.
app createcommand will bootpstrap your app (behind the scenes it will run the
cap installcommand and add some customizations)
Some files and folders will be added to your project. ```ruby project_root |--- Capfile # Capistrano load file +--- config |--- deploy.rb # Global setting for all environments ```
Add a new stage for your deployment.
$negroku stage add
This will be used to create de stage configuration files
Select the branch to use
Here you'll be presented with your remote branches (git branch -r) so you can choose which one you want to deploy the stage you are creating.
Type the domains to use
You can pass comma separated domains you want to use in the application
Type the server ur to deploy to
Set the server where you are going to deploy this stage
Do you want to add rbenv-vars to the server now?
If you choose 'y'es you wil able to create a
.rbenv-varsfile in the server with the KEYS and VALUES you choose from your local
stage addcommand will create the stage configuration file and run the
rbenv:vars:addcapistrano task if you chosen to add environmental variables to the applicatin
project_root +--- config +--- deploy +--- production.rb # Specific settings for production server
Capfileyou can enable and disabled the tasks you need in your application. You only have to comment out the stuff you don't need.
# Node require 'capistrano/nodenv' # require 'capistrano/bower' # App server require 'capistrano3/unicorn' # Static server require 'capistrano/nginx'
Configure your specific settings in the files created above
Common settings for all stages
Here you can add all the settings that are common to all the stage severs. For example:
set :unicorn_workers, 1 set :unicorn_workers_timeout, 30
Here you can add all the settings that are specific to the stage. For example:
set :branch, "production" # Optional, defaults to master set :rails_env, "production"
Commit and push the changes to the repository
Deploy you application
To deploy your application you just need to run capistrano task to do so.
$ cap staging deploy # to deploy to the staging stage
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
Thank you contributors!
negroku is maintained by platanus.
Guides is © 2014 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.