Project 7.1: Team Coordination and Environment Setup

March 22, 2011

Objective

Get your team up and running in a collaborative environment, set up production and staging, and get the basics deployed to the cloud.

Requirements

Here are the following steps you should follow to get up and running.

Choose Your Team [COMPLETE]

Teams should consist of just two people. Use the forum and face-to-face coordination to find a teammate if you don't have one in mind. Once your team is chosen, be sure to post accordingly on this ore thread.

Team list is here.

Get a Heroku Account

Visit https://api.heroku.com/signup and get a Heroku account. You do not need to "verify" your account with a credit card -- I'll host the applications on my account for you, and enable certain freemium features.

Once you have your heroku account, you must email me your heroku username.

Fork the Application Skeleton

I'm going to provide you a basic Rails application to help save us some time. It's very similar to what we created for Project 6, but we'll have the advantage of all starting from the same codebase. You should:

Important: don't try to execute a git clone from within your existing repo. This will create a repository inside a repository, which doesn't work (don't worry about git submodules, if you're aware of them). This is an entirely new repository, completely separate from your existing 446 repo.

This portion is complete if ybakos can clone the repository and push changes.

You should both experiment with pushing and pulling, since this is our first collaborative project. For example, both of you should try making simple changes to the README (add your own names to the README, for example) to start experiencing this workflow.

Get the Application Running within your Dev Env

Here are the steps you'll need to follow in order to get the application running.

Install bundler

Bundler is a tool for managing gem dependencies of your application.

gem install bundler (or sudo gem install bundler)

Next, from within your repo root:

bundle install (or sudo gem bundle install)

Bundler will then download and install all the gem dependencies for the application. (Go have some orange juice while your machine does the work).

Create a database.yml

A file called database.example.yml exists in config/. Simply copy it:

cp config/database.example.yml config/database.yml

Update db/seeds.rb

Next, update the seed data appropriately (leave passwords alone, change them later via the app itself). I've tried to make it obvious where you need to make changes (for example, names and email addresses).

Setup the database

Running rake db:setup will create the database, run the migrations, and plant your seed data.

Run the application

Run your application (eg, script/server) and poke around, log in, etc. Don't worry about all those "FIXME's," we'll get to those soon. (If they're itching, then by all means scratch that itch).

Deploy the application to heroku

First, you should created a heroku account and have sent me your heroku username via email. There are three things we'll need to do to get your app up an running in the cloud.

Edit .git/config

Deploying to heroku is as simple as pushing your repository. First, we'll need to add the two new heroku remotes to your local repository. Take a look at this spreadsheet and make a note of your staging and production application names. Next, from your repo root, edit the file .git/config. It should have three sections that look something like this:

[remote "origin"]
  url = git@github.com:YOU_OR_PARTNERS_USERNAME/YOUR-REPO-NAME.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
  remote = origin
  merge = refs/heads/master
[remote "staging"]
  url = git@heroku.com:STAGING-APP-NAME.git
  fetch = +refs/heads/*:refs/remotes/heroku/*
[remote "production"]
  url = git@heroku.com:PRODUCTION-APP-NAME.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

You'll need to add the "staging" and "production" sections, replacing the items in ALL-CAPS with your respective staging and production app names, for example, spicy-fruit-123.

Once you've made that change, first inform Heroku of who you are:

heroku keys:add

Next, push the application to your staging environment like so:

git push staging master

You may get prompted by Heroku to provide some information such as your Heroku username. Simply follow the prompts. In the end, you should see some output from heroku regarding the deployment of your application. The first time you push your application with a specific Gemfile and Gemfile.lock, it will take some time for Heroku to configure your environment. Subsequent deployments will be faster.

Next, migrate and seed your database like so:

heroku rake db:migrate --app APP-NAME-123
heroku rake db:seed --app APP-NAME-123
heroku restart --app APP-NAME-123

Of course, replace "APP-NAME-123" with your staging app name such as "sweet-chicken-456". The heroku command looks at .git/config and notices we have multiple heroku remotes, so we have to specify the --app option. (If you get tired of this, use heroku_san. But you don't have to.)

At this point, you should be able to visit http://APP-NAME-123.heroku.com, visit the login screen, and log in to your application. If you see an error page, an exception is being raised in your environment and you should check the log like so:

heroku logs --app APP-NAME-123

Conclusion

That's it! At least, for this part of the project. You should now have the application working in your local development environment, and also on staging.

What's next?

Once you've gotten this far, move on to Project 7.2.

Grading criteria (1000 points)

We must be able to visit http://YOUR-APP.heroku.com and and log in successfully.

These tasks are due by Monday, April 4 @ 11:59PM.