DWELL - a cap recipe to setup a full Rails stack on Ubuntu
Install Capistrano2 (if you don't already have it) then build and install this gem:
$ sudo gem install capistrano
$ gem build dwell.gemspec
$ sudo gem install dwell-0.2.gem
Typical Usage
- Capify your Rails directory
- Initialize dwell inside your Rails directory (you'll want to overwrite deploy.rb)
- Edit your deploy.rb: configure you applications name, domain, repository, server details, etc
- Bootstrap your server
- Install the Dwell stack and any optional packages
- Setup your rails app and apache vhost then deploy cold
Or all said and done:
$ capify .
$ dwell init .
$ cap dwell:server:bootstrap
$ cap dwell:install
$ cap dwell:rails:setup_and_deploy_cold
The Dwell Stack - dwell:install
- Updates Ubuntu sources and distro
- Installs Apache2
- Installs MySQL5
- Installs Subversion and Git
- Installs Ruby, RubyGems, Rails and Merb
- Installs Passenger module for Apache2
- Installs any optional packages listed in
:dwell_optional_installs
Optional Packages
You can specify optional packages to be installed during dwell:install
in your deploy.rb file:
set :dwell_optional_installs, [:postfix, :imagemagick, :php]
Optional packages include:
- postfix
- mercurial
- tinydns
- php (sets up php via fastcig)
- imagemagick (binary, gem, and mini-magick gem)
- sqlite (binary and gem)
Bootstrapping
dwell:server:bootstrap
- Creates a user account for
:user
(default 'deploy') in the admin group - Gives the admin group sudo rights if they haven't already
- Copies authorized SSH keys to the remote host (such as your own public key)
- Disables SSH logins for the root account since we'll be using deploy and sudo
Authorized keys should be placed in the file (:user is the name of your deploy user):
config/dwell//:user
dwell:linode:bootstrap
- Does a
dwell:server:bootstrap
as show above - Uses the DHCP IP assignment to configure a static IP and disable DHCP
- Sets up the hostname of the box from what was passed in HOSTS
You MUST pass the host (singular) in HOSTS to bootstrap a Linode as the bootstrap needs to know the hostname to properly configure the box.
HOSTS="my.new.box.com" cap dwell:linode:bootstrap
Rails Notes - dwell:rails
dwell:rails:setup_and_deploy_cold
- Does a traditional
cap:setup
- Copies deploy keys (if found) to the remote host (needed for git, etc)
- Creates a mysql database with the authentication info in your database.yml
- Sets up an apache vhost and SSL keys (if you're using SSL)
- Deploys your code
- Installs any necessary app gems with
rake gems:install
- Runs migrations
- Reloads Apache which should fire up your app
Optional deploy keys (public and private) should be placed in deploy_keys
:
config/dwell/deploy_keys/:user.pub
config/dwell/deploy_keys/:user
Apache Notes - dwell:apache
SSL certificates (if found) will be copied and installed during setup_and_deploy_cold
. You can also do this manually with cap dwell:apache:copy_certs
. These same certs will referenced automatically in your apache configs if you have set :apache_ssl_enabled
in your deploy.rb.
SSL certificates should be saved locally:
config/dwell/ssl/ca/*.crt
config/dwell/ssl/*.crt
config/dwell/ssl/*.key
Any keys inside ssl/ca
are assumed to be a Certificate Authority and are added to your Apache config with SSLCACertificateFile
.