- Ruby 2.3.5
- PostgreSQL 9.x
- Elasticsearch 1.5+
- A cloud.gov account
- An SMTP server (
productionmode only)
C2 is a fairly typical Rails application, so the setup is straightforward:
-
If you're installing on a development machine, we recommend using
rbenvto manage your Ruby environment, especially since we've had problems withrvm. On a Mac, you can use Homebrew to install it (along withruby-build).brew install rbenv postgresql rbenv init rbenv install 2.3.5 gem install bundler bundle
-
Run the setup script to create a user record for your email address, make that user an admin, and add a few records for that user.
git clone https://github.com/18F/C2.git cd C2 # Will print "DONE" if successful. NOTE: This will delete any existing records in your C2 database and add a few seed records. ./script/bootstrap YOUR_EMAIL@gsa.gov
-
Per the Twelve-Factor guidelines, all necessary configuration should be possible through environment variables. (See
.env.examplefor the full list.)Your configuration will go in the
.envfile that thebootstrapscript creates..env.exampleexists as an example. -
Register an application on cloud.gov.
- Give the application a Name that gives cloud.gov admins a good idea of what it is and who set it up; e.g.
c2-prod. Optionally create multiple instances:c2-prod,c2-staging,c2-dev, for example. - Set the Url field to the URL for your setup. If you're running the app locally, the default URL is
http://localhost:3000/ - Set the Redirect uri field to
[your_C2_url]/auth/cg/callback. For example, with the default URL:http://localhost:3000/auth/cg/callback
- Give the application a Name that gives cloud.gov admins a good idea of what it is and who set it up; e.g.
-
Once you've registered the application, cloud.gov will give you two consumer key strings for saving: the App ID and App Secret. Add these to your
.env, settingCG_APP_IDto the App ID andCG_APP_SECRETto the App Secret. -
To test locally, you need to use fake-cloud.gov:
- Download the binary for cg-fake-uaa
- From the directory your binary is in, run
chmod +x cg-fake-uaa - Run the binary, passing it the correct URL for your local instance's callback:
./cg-fake-uaa -callback-url http://localhost:3000/auth/cg/callback - When
cg-fake-uaais run it will print an OAuth2 authorize URL and a token URL. In your C2.envfile, add these asCG_URLandCG_TOKEN_URLrespectively. (Note: At time of writing, using the full token URL suggested bycg-fake-uaawill cause errors when trying to log in with C2. For the moment, setCG_TOKEN_URLto justhttp://localhost:8080/(or whichever portcg-fake-uaais using)
The fake version simply asks for an email address and redirects that email address back to your callback. It does not look like the actual cloud.gov login flow.
- Check that PostgreSQL is running
- Set the
DATABASE_URLvariable in.envto match your setup
- To install a compatible Elasticsearch locally:
brew install elasticsearch@2.4- Note the
TEST_CLUSTER_COMMANDin.env.example, you may need to un-comment it before tests will run. - Check that Elasticsearch is running (default is localhost:9200)
- Set the
ES_URLvariable in.envto match your setup
rbenv rehash
gem install foreman./script/start
open http://localhost:3000The bootstrap script you ran during installation creates a user record for the
email address passed in (which should be yours), makes that user an admin, and
creates relevant records for that user.
If you'd like to generate more records, you can run the following rake task:
bin/rake populate:ncr:for_user[YOUR_EMAIL@gsa.gov]Now you should see 25 pending purchase requests at http://localhost:3000/proposals.
As emails are sent, they will be visible at http://localhost:3000/letter_opener.
If you are working on an email mailer/template, you can view all of them at http://localhost:3000/rails/mailers.
You will need to install PhantomJS and have it in your PATH. This is used for javascript and interface testing.
brew install phantomjsrake db:test:prepare
./bin/rakebundle exec guardgem install brakeman
brakemanor just visit the project on Gemnasium.
rake search:import NPROCS=2 FORCE=y