Coder Social home page Coder Social logo

capistrano-cook's Introduction

Summary

The goal of capistrano-cook is to make single-server Rails hosting solutions a breeze to set up. It started out as a collection of the recipes presented on RailsCasts on server provisioning based on Capistrano. Since then, the recipes have been extended and adapted. capistrano-cook has primarily been tested on Ubuntu 12.04 LTS.

Getting Started

Add to your Gemfile:

gem 'capistrano-cook', :git => 'https://github.com/subsis/capistrano-cook.git', :require => false

Also, add gem "unicorn", :group => :production, if you haven't already. Then run:

bundle install

To use the default configuration, add the following to your config/deploy.rb file:

require "capistrano-cook"

This will include recipes for the default setup (see below for a description). If you want to customize your deployment setup, check out the wiki.

You need to configure Capistrano as you would otherwise. The following is an example of a minimal config/deploy.rb-file:

require "bundler/capistrano"
require "capistrano-cook"

server "77.66.59.249", :app, :web, :db, :primary => true

set :domain,    "mydomain.com"
set :rails_env, :production

set :application, "myappname"
set :user,        "myappname"

set :scm,         "git"
set :repository,  "[email protected]:myorganization/myappname.git"
set :branch,      "production"
set :deploy_to,   "/var/www/#{application}"
set :deploy_via,  :remote_cache

set :use_sudo,      true

default_run_options[:pty]   = true
ssh_options[:forward_agent] = true

Now you're ready to set up the server, and we need to create a deployment user (you will be prompted for the password of the root-user):

cap root:add_user

This will create a sudo user with the same name as your app, and prompt for a password. Then install the required packages:

cap deploy:install

You're now ready to set up your app, and deploy it for the first time:

cap deploy:setup deploy:cold

This will create deployment folder structure under /var/www/myappname, create the database, install your app as a service, and configure Nginx.

Default Stack

The default stack is configured as follows:

  • MySQL 5.7
  • Nginx (from ppa:nginx/stable)
  • Ruby 1.9.3-p125
  • rbenv
  • Unicorn with rolling restarts (as describe in RailsCast 373. Installed as an sysinit service. Defaults to 2 workers processes.
  • Monit monitors Unicorn worker processes, and gracefully restarts workers that use more than 120MB RAM, or an average of 25% CPU over 2 minutes.
  • logrotate with weekly rotation, 10 weeks compressed history.
  • nodejs (from ppa:chris-lea/node.js) for asset precompilation.

capistrano-cook's People

Contributors

nicholassm avatar kacperk avatar

Stargazers

Daniel Marchlik avatar Javi Rubio avatar  avatar  avatar  avatar Peter Ericson avatar Nicolaj S. Lindtner avatar

Watchers

Andreas Garnaes avatar James Gorlick avatar James Cloos avatar  avatar

capistrano-cook's Issues

SSL support

If SSL is enabled, the generated nginx config file should support SSL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.