- Ruby 2.2.3
- PostgreSQL 9.x
- Elasticsearch 1.5+
- A MyUSA account
- An SMTP server (
production
mode only)
C2 is a fairly typical Rails application, so the setup is straightforward:
-
Run
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
-
Per the Twelve-Factor guidelines, all necessary configuration should be possible through environment variables. (See
.env.example
for the full list.)Your configuration will go in the
.env
file. Create it by copying.env.example
:cp .env.example .env
-
Register an application on MyUSA.
- Give the application a Name that gives MyUSA admins a good idea of what it is and who set it up; e.g.
Janet's laptop C2
- 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/myusa/callback
. For example, with the default URL:http://localhost:3000/auth/myusa/callback
- In the "Select the API Scopes..." section, select:
- Email Address
- First Name
- Last Name
- By default, new applications on MyUSA have a status of Private, which means that only the MyUSA user who registered the app can log in. If you need other people to log into your C2 setup, then your app will need a status of Public. (This matters for staging servers more than local development, so you probably don't need to worry about it.)
Since Public apps need to be approved by MyUSA admins before they're usable, it's best to leave the status as Private when setting up, then change it to Public later.
- Give the application a Name that gives MyUSA admins a good idea of what it is and who set it up; e.g.
-
Once you've registered the application, MyUSA will give you two consumer key strings for saving: the Public Key and Secret Key. Add these to your
.env
, settingMYUSA_KEY
to the Public Key andMYUSA_SECRET
to the Secret Key.
- Check that PostgreSQL is running
- Set the
DATABASE_URL
variable in.env
to match your setup
- Check that Elasticsearch is running (default is localhost:9200)
- Set the
ES_URL
variable in.env
to match your setup
rbenv rehash
gem install foreman
This is likely because your MyUSA app registration is marked Private. To get Public status, go to your developer applications list and click Request Public Access; this will send a message to the MyUSA admins. (If your application's status hasn't changed after one business day, try mailing the MyUSA team; if you're an 18F employee, ask in the #myusa
Slack channel.)
./script/start
open http://localhost:3000
Once you've authed locally, there will be a user
record associated with your
email address. There won't be much for you to see until your client slug is set,
so find your user record and set it to ncr
:
bin/rails c
user = User.find_by(email_address: '[email protected]')
user.update(client_slug: 'ncr')
Now you will see the link to create a new work order locally.
If you'd like to seed your dashboard with work orders, you can run this rake task:
bin/rake populate:ncr:for_user[[email protected]]
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.
./bin/rake
bundle exec guard
gem install brakeman
brakeman
or just visit the project on Gemnasium.
rake search:import NPROCS=2 FORCE=y