Skip to content

Commit

Permalink
Dockerize properly, and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkesh Vaghmaria committed Feb 7, 2017
1 parent 8ee42c8 commit 5c5709c
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Ignore bundler config.
/.bundle

public/assets/
public/system/

# Ignore the default SQLite database.
Expand Down
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
FROM ruby:2.3
RUN mkdir /app

WORKDIR /app
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install
ADD . /app

ADD Gemfile* /app/

RUN gem install bundler && bundle config build.nokogiri --use-system-libraries && bundle install --jobs 16 --retry 5 --without development test

ADD . /app

EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,30 @@ Spectre is a web application to diff screenshots. It's heavily influenced by [Vi
![Spectre!](spectre_screenshot_1.png)
![Spectre!](spectre_screenshot_2.png)

## Requirements
## Running the app

You can either run the app using [docker](https://www.docker.com), or you can run it natively on your machine – there are instructions for both docker,
and running on macOS below.

Alternatively, you can run the application on [Heroku](https://www.heroku.com/).

### Running using docker

Install [docker](https://www.docker.com/products/docker)

Setup the database (only needs to be done once):

docker-compose run --rm app bundle exec rake db:setup

To run the application:

docker-compose up

When you see `WEBrick::HTTPServer#start: pid=2 port=3000`, the app will be running at http://localhost:3000

### Running natively on macOS

#### Prerequisites

* Ruby (doesn't currently work with v2.4.0)
* Postgres
Expand All @@ -20,14 +43,14 @@ On a Mac, the easiest way to install the above, is to use [homebrew](http://brew
1. `brew install imagemagick`
1. `brew install postgresql` and follow the instructions it prints about starting the postgresql server

## Setup
#### Setup

* Clone the repo
* `bundle install && bundle exec rake db:setup`
* `bundle exec rails s`
* Copy `.env.example` and rename to `.env`. Change the url details if you need to.

Alternatively:
### Running on Heroku:

[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Expand Down Expand Up @@ -72,6 +95,8 @@ An example test run can be executed using:

Spectre doesn't provide a UI or API to edit or delete content. We've included `rails_admin`, so head to `/admin` for this. By default there is no password.

## Tests
## Contributing

### Tests

[Rspec](http://rspec.info/) and [Cucumber](https://cucumber.io) are included in the project. Test coverage is minimal but please don't follow our lead, write tests for anything you add. Use `rspec && rake cucumber` to run the existing tests.
26 changes: 11 additions & 15 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
development:
default: &default
adapter: postgresql
encoding: utf8
database: spectre_development
pool: 5
username:
password:

production:
adapter: postgresql
encoding: utf8
database: wafi-spectre
pool: 5
username: deploy
port: 5432
timeout: 5000

development:
<<: *default
database: spectre_development

test: &test
adapter: postgresql
encoding: utf8
<<: *default
database: spectre_test
pool: 5
username:
password:

cucumber:
<<: *test

production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
35 changes: 24 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
version: "2"

services:
web:
app:
build: .
volumes:
- .:/app
ports:
- "3000:3000"
env_file:
- '.env.example'
command: bundle exec rails s -b '0.0.0.0'
depends_on:
- db
- "3000:3000"
links:
- db
environment:
- RACK_ENV=production
- RAILS_SERVE_STATIC_FILES=true
- DATABASE_URL=postgresql://postgres@db/spectre
volumes:
- .:/app
command: bash -c "rm -f /app/tmp/pids/*.pid && rake assets:precompile && SECRET_KEY_BASE=`rake secret` rails server -b 0.0.0.0"

db:
image: postgres
image: postgres:9.4
ports:
- "5432"
- "5432"
volumes:
- .:/app
- .:/public
- data-db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=spectre

volumes:
data-db: {}

0 comments on commit 5c5709c

Please sign in to comment.