Skip to content

Commit

Permalink
Add docker
Browse files Browse the repository at this point in the history
Update docker and README

Add ruby version

Update README

Update bundler until bugs are fixed

Clean up Dockerfile and remove Ansible

Remove Ansible shell scripts

Update setup scripts and dockerfile again

Update bin and colors

Update docs
  • Loading branch information
joshsmith committed Jul 8, 2016
1 parent e606363 commit 1fc54b5
Show file tree
Hide file tree
Showing 137 changed files with 415 additions and 2,954 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

# ignore the Ruby Version manager (rvm)
.rvmrc
.ruby-version
.ruby-gemset
.rbenv
bundler_stubs/*
Expand Down
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--color
--tty
--require spec_helper
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.5
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ruby:2.2.5

RUN gem update --system 2.6.1
RUN gem install bundler --version $BUNDLER_VERSION

RUN apt-get update -qq && apt-get install -y build-essential

# ImageMagick
RUN apt-get install -y imagemagick

# PostgreSQL
RUN apt-get install -y libpq-dev

# Node.js runtime
RUN apt-get install -y nodejs

# Set directory for our app
ENV APP_HOME /code-corps-api
RUN mkdir $APP_HOME

# Copy Gemfile and bundle
WORKDIR $APP_HOME
COPY Gemfile $APP_HOME/Gemfile
COPY Gemfile.lock $APP_HOME/Gemfile.lock
RUN bundle install

# Copy code
ADD . $APP_HOME
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"
ruby "2.2.3"
ruby "2.2.5"

gem "rails", "5.0.0"

Expand Down Expand Up @@ -57,7 +57,9 @@ end

group :development do
gem "foreman"
gem "guard-rspec", require: false
gem "sinatra", github: "sinatra", require: nil # for Sidekiq UI to work in development
gem "spring-commands-rspec"
end

group :test do
Expand Down
34 changes: 34 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,28 @@ GEM
redis (~> 3.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.13)
foreman (0.82.0)
thor (~> 0.19.1)
formatador (0.2.5)
full-name-splitter (0.1.2)
github-markdown (0.6.9)
globalid (0.3.6)
activesupport (>= 4.1.0)
guard (2.14.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.2)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
hashdiff (0.3.0)
hashie (3.4.4)
html-pipeline (1.11.0)
Expand All @@ -190,8 +206,13 @@ GEM
addressable
faraday
multi_json
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
nokogiri (>= 1.5.9)
lumberjack (1.0.10)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
Expand All @@ -206,11 +227,15 @@ GEM
multipart-post (2.0.0)
mustermann (0.4.0)
tool (~> 0.2)
nenv (0.3.0)
newrelic_rpm (3.16.0.318)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
notiffany (0.1.0)
nenv (~> 0.1)
shellany (~> 0.0)
oauth2 (1.2.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
Expand Down Expand Up @@ -282,6 +307,9 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redis (3.3.0)
rouge (1.11.1)
rspec (3.5.0)
Expand All @@ -308,6 +336,7 @@ GEM
rspec (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0)
rspec-support (3.5.0)
ruby_dep (1.3.1)
safe_yaml (1.0.4)
searchkick (1.3.0)
activemodel
Expand All @@ -321,6 +350,7 @@ GEM
sequenced (3.1.1)
activerecord (>= 3.0)
activesupport (>= 3.0)
shellany (0.0.1)
shoulda-matchers (3.0.1)
activesupport (>= 4.0.0)
sidekiq (4.1.2)
Expand All @@ -334,6 +364,8 @@ GEM
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.7.2)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (3.6.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -388,6 +420,7 @@ DEPENDENCIES
foreman
full-name-splitter
github-markdown
guard-rspec
hashie
html-pipeline
html-pipeline-rouge_filter
Expand Down Expand Up @@ -420,6 +453,7 @@ DEPENDENCIES
sidekiq
sinatra!
spring
spring-commands-rspec
strip_attributes
vcr
webmock
Expand Down
70 changes: 70 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end
1 change: 0 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -q high -q default -q low
redis: redis-server
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ We'd love to have you contribute to Code Corps directly!

To do so, please read the guidelines in our [`CONTRIBUTING.md`](CONTRIBUTING.md).

Then head over to [Code Corps](https://codecorps.org), where we manage contributions.
Then check out some GitHub issues to see where you can help out.

## Developer installation guide

### Recommended install

To make your life easier, you can just clone this repository and use our Vagrant development box. [Follow this guide to get started.](docs/DEFAULT_INSTALL.md)
To make your life easier, you can just clone this repository and use our Docker container. [Follow this guide to get started.](docs/DEFAULT_INSTALL.md)

#### Custom install

We wholeheartedly recommend against doing a custom install. You'll be spending more time configuring and less time being productive. But if you'd like to work that way, you can read our [custom install guide](docs/CUSTOM_INSTALL.md).

### Working with Ember

### Serving Ember

The Code Corps API is intended to work alongside a client written in Ember. For that purpose, the Rails application exposes all of its API endpoints behind an `api.` subdomain.

Expand All @@ -42,7 +43,7 @@ Any server request pointing to the main domain and not the `api.` subdomain is r
* a plain text string containing "INDEX NOT FOUND" if a revision was specified, but the key for the specified revision was not found by redis


### Debugging the API
### Debugging

Because the app is running `foreman`, debugging using `pry` won't work the same way. If you want to use `pry`, you'll need to [debug remotely](https://github.com/nixme/pry-debugger#remote-debugging).

Expand All @@ -60,11 +61,15 @@ end
Load a page or make a request that triggers the code. Connect to the session:

```shell
$ bundle exec pry-remote
$ docker-compose run web pry-remote
```

## Built with

- [Rails::API](https://github.com/rails-api/rails-api) — Our backend API is a Rails::API app which uses JSON API to respond RESTfully to requests.
- [Ember.js](https://github.com/emberjs/ember.js) — Our frontend is an Ember.js app that communicates with the Rails API.
- [PostgreSQL](http://www.postgresql.org/) — Our primary data store uses Postgres.
- [Rails](http://edgeguides.rubyonrails.org/api_app.html) — Our backend API uses Rails 5 in its API-only configuration.
- [ActiveModelSerializers](https://github.com/rails-api/active_model_serializers) - We use AMS to serialize the JSON responses from our API.
- [Ember.js](https://github.com/emberjs/ember.js) — Our frontend is an Ember.js app that communicates with the Rails JSON API.
- [PostgreSQL](http://www.postgresql.org/) — Our primary data store.
- [Redis](http://redis.io/) — Redis for a variety of NoSQL uses.
- [Elasticsearch](https://www.elastic.co/products/elasticsearch) — Elasticsearch for searching documents.
- [Docker](https://www.docker.com) — Docker for containerized development environments.
Loading

0 comments on commit 1fc54b5

Please sign in to comment.