Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ruby:2.3.1

RUN apt-get update -qq && apt-get install -y \
build-essential \
libpq-dev \
nodejs \
nodejs-legacy \
npm \
netcat

RUN npm install -g phantomjs-prebuilt
RUN mkdir /rails
WORKDIR /rails
ADD Gemfile /rails/Gemfile
ADD Gemfile.lock /rails/Gemfile.lock
RUN bundle install
ADD . /rails
RUN gem install foreman
RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /usr/local/bin/wait-for-it
RUN chmod +x /usr/local/bin/wait-for-it
CMD wait-for-it db:5432 && bundle exec rake dev:prime && \
foreman start
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gem "rails", "4.2.7.1"

gem "actionmailer-text", "~> 0.1.1"
gem "active_model_serializers", "~> 0.9.4"
gem "activeadmin", git: "https://github.com/activeadmin/activeadmin.git"
gem "activeadmin", "~>1.0.0.pre2"
gem "activeadmin_hstore_editor", "0.0.5"
gem "acts_as_list"
gem "acts-as-taggable-on", "~> 3.4"
Expand Down Expand Up @@ -59,6 +59,7 @@ gem "sass-rails", ">= 3.2"
gem "simple_form"
gem "simple_form_object"
gem "sprockets-rails", "< 3" # https://github.com/jfirebaugh/konacha/issues/216
gem "therubyracer"
gem "uglifier"
gem "validates_email_format_of"
gem "workflow"
Expand Down
62 changes: 32 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ GIT
omniauth (~> 1.0)
omniauth-oauth2 (= 1.3.1)

GIT
remote: https://github.com/activeadmin/activeadmin.git
revision: ca94d1ccb1894ccbaedc40f6a6b948d1423b90bb
specs:
activeadmin (1.0.0.pre2)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails
kaminari (~> 0.15)
rails (>= 3.2, < 5.0)
ransack (~> 1.3)
sass-rails

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -52,6 +34,20 @@ GEM
rails-html-sanitizer (~> 1.0, >= 1.0.2)
active_model_serializers (0.9.4)
activemodel (>= 3.2)
activeadmin (1.0.0.pre4)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails
kaminari (~> 0.15)
rails (>= 3.2, < 5.1)
ransack (~> 1.3)
sass-rails
sprockets (< 4)
activeadmin_hstore_editor (0.0.5)
railties (>= 3.0, < 5.0)
activejob (4.2.7.1)
Expand Down Expand Up @@ -89,7 +85,7 @@ GEM
ansi (1.5.0)
ar_outer_joins (0.2.0)
activerecord (>= 3.2)
arbre (1.0.3)
arbre (1.1.1)
activesupport (>= 3.0.0)
arel (6.0.3)
atomic (1.1.99)
Expand All @@ -105,7 +101,7 @@ GEM
blazer (1.1.0)
chartkick
rails
bourbon (4.2.6)
bourbon (4.2.7)
sass (~> 3.4)
thor (~> 0.19)
browser (2.2.0)
Expand Down Expand Up @@ -136,9 +132,9 @@ GEM
codeclimate-test-reporter (0.4.8)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
railties (>= 4.0.0, < 5.2.x)
coffee-script (2.4.1)
coffee-script-source
execjs
Expand Down Expand Up @@ -211,9 +207,9 @@ GEM
foreman (0.78.0)
thor (~> 0.19.1)
formatador (0.2.5)
formtastic (3.1.3)
formtastic (3.1.4)
actionpack (>= 3.2.13)
formtastic_i18n (0.5.0)
formtastic_i18n (0.6.0)
fuubar (2.0.0)
rspec (~> 3.0)
ruby-progressbar (~> 1.4)
Expand Down Expand Up @@ -292,6 +288,7 @@ GEM
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
libv8 (3.16.14.17)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand Down Expand Up @@ -366,7 +363,7 @@ GEM
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyamorous (1.3.0)
polyamorous (1.3.1)
activerecord (>= 3.0)
pry (0.10.3)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -424,19 +421,20 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.3.0)
ransack (1.7.0)
ransack (1.8.2)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.2)
polyamorous (~> 1.3)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redcarpet (3.3.4)
ref (2.0.0)
referer-parser (0.3.0)
request_store (1.3.1)
responders (2.1.1)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
roadie (3.1.1)
css_parser (~> 1.3.4)
Expand Down Expand Up @@ -511,6 +509,9 @@ GEM
sprockets (>= 2.8, < 4.0)
test_after_commit (1.0.0)
activerecord (>= 3.2)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
Expand Down Expand Up @@ -543,7 +544,7 @@ PLATFORMS
DEPENDENCIES
actionmailer-text (~> 0.1.1)
active_model_serializers (~> 0.9.4)
activeadmin!
activeadmin (~> 1.0.0.pre2)
activeadmin_hstore_editor (= 0.0.5)
acts-as-taggable-on (~> 3.4)
acts_as_list
Expand Down Expand Up @@ -626,6 +627,7 @@ DEPENDENCIES
spring-commands-rspec
sprockets-rails (< 3)
test_after_commit
therubyracer
timecop
uglifier
validates_email_format_of
Expand All @@ -637,4 +639,4 @@ RUBY VERSION
ruby 2.3.1p112

BUNDLED WITH
1.13.2
1.13.6
26 changes: 26 additions & 0 deletions bin/docker-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

set -x

# wait for postgresql
until nc -vz $POSTGRESQL_HOST 5432; do
echo "Postgresql is not ready, sleeping..."
sleep 1
done
echo "Postgresql is ready, starting Rails."

# wait for elasticsearch
until nc -vz $ELASTICSEARCH_HOST 9200; do
echo "Elasticsearch is not ready, sleeping..."
sleep 1
done
echo "Elasticsearch is ready, starting Rails."

# optional
# rm /rails/tmp/pids/server.pid

# setup database and start puma
RAILS_ENV=development bundle exec rake db:create
RAILS_ENV=development bundle exec rake db:migrate
RAILS_ENV=development bundle exec rake db:seed
RAILS_ENV=development bundle exec rails s -p 3000 -b '0.0.0.0'
4 changes: 4 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ default: &default
development:
<<: *default
database: c2_development
username: <%= ENV['DATABASE_USER'] or '' %>
password: <%= ENV['DATABASE_PASSWORD'] or '' %>
host: <%= ENV['DATABASE_HOST'] or '' %>

pool: 6
test:
<<: *default
Expand Down
51 changes: 51 additions & 0 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,54 @@ or just [visit the project on Gemnasium](https://gemnasium.com/18F/C2).
```bash
rake search:import NPROCS=2 FORCE=y
```


### Using Docker

A development instance of the C2 application can be spun up quickly
using [Docker Compose](https://docs.docker.com/compose/).

#### Setup

1. [Install docker-compose](https://docs.docker.com/compose/install/).

2. If you're using `boot2docker` (e.g., on OSX), start up `boot2docker`
(`boot2docker init` and then `boot2docker up`), then get the local IP address
of the VM with `boot2docker ip`. The output of this will be the local URL you'll
access. So if the IP is `192.168.59.103/`, you'll access the site locally at
`http://192.168.59.103:3000`.

3. Update the GitHub application callback URLs to use the IP address (start
[here](https://github.com/settings/developers)).

After setting your Github application credentials in your `.env` file as
described above, start up the database and application server using
`docker-compose`.

#### Running

It's as simple as:

```
$ docker-compose up
```

And visiting `[the IP from boot2docker IP]:5000`.

The sample data will be populated in the database automatically.

To run the tests:

```
$ docker-compose run web bundle exec rake spec
```

You should be able to run any Rails command by prepending it with `docker-compose run web`.


#### Using Docker

```
docker-compose up -d
docker-compose run web bundle exec rake spec
```
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '2'
services:
elasticsearch:
image: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
volumes:
- elasticsearch:/usr/share/elasticsearch/data
postgres:
image: postgres
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
redis:
image: redis
ports:
- "6379:6379"
volumes:
- redis:/data
web:
build: .
command: bin/docker-start
environment:
- ELASTICSEARCH_HOST=elasticsearch
- POSTGRESQL_HOST=postgres
- POSTGRESQL_PASSWORD=
- POSTGRESQL_USERNAME=postgres
- REDIS_HOST=redis
- [email protected]
links:
- postgres
- elasticsearch
- redis
volumes:
- .:/rails
ports:
- "3000:3000"
depends_on:
- postgres
- elasticsearch
- redis
volumes:
elasticsearch: {}
postgres: {}
redis: {}
2 changes: 2 additions & 0 deletions script/start
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

bundle check || bundle install

set -e
set -x

Expand Down