Skip to content

Instantly share code, notes, and snippets.

@bswinnerton
Last active January 4, 2016 13:29
Show Gist options
  • Save bswinnerton/8627961 to your computer and use it in GitHub Desktop.
Save bswinnerton/8627961 to your computer and use it in GitHub Desktop.

#Ruby on Rails Office Hours - Session 2 ##Brewing your own server with Chef and Capistrano on Digital Ocean

Google hangout: http://www.youtube.com/watch?v=3W4kXyZWDJA
Real time chat: http://tlk.io/ror-study-group
Chef Notes: https://github.com/intercity/chef-repo

Code Along

  1. Create a droplet on Digital Ocean

  2. Install Chef on your computer:

    cd ~/Sites/
    git clone git@github.com:ror-study-group/chef-repo.git
    cd chef-repo
    rbenv install 2.0.0-p247
    gem install bundler
    bundle install
    
  3. Configure and Deploy your server environment:

    bundle exec knife solo prepare root@<ip-address>
    cp nodes/sample_host.json nodes/<ip-address>.json #Fill in appropriate information
    bundle exec knife solo cook root@<ip-address>
    
  4. Create Rails app:

    rails new ror-study-group
    cd ror-study-group
    git init .
    git add .
    git commit -m "Initial rails install"
    vi Gemfile #add MySQL
    rails g scaffold message_board title:string body:text
    rake db:migrate
    git add .
    git commit -m "Adding message board support"
    git remote add origin git@github.com:bswinnerton/ror-study-group.git
    git push origin master
    
  5. Add Capistrano to app:

    rbenv local 2.0.0-p247
    echo "\ngem 'unicorn'\ngem 'capistrano', '~> 2.15'" >> Gemfile
    bundle install
    bundle binstub unicorn
    bundle exec capify .
    vi Capfile #uncomment deploy/assets
    vi config/deploy.rb #https://github.com/intercity/chef-repo
    git add .
    git commit -m "Adding production support"
    git push origin master
    
  6. Prepare Capistrano

    bundle exec cap deploy:setup
    bundle exec cap deploy:check
    bundle exec cap deploy:cold
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment