Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #435

Merged
merged 12 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from 11 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
14 changes: 0 additions & 14 deletions .rake/vagrant.rb

This file was deleted.

11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
language: ruby
cache: bundler
services: docker
before_install:
- docker-compose build
script:
- bundle exec rake db:setup RAILS_ENV=test
- bundle exec rake db:test:prepare
- bundle exec rake spec
- bundle exec rake cucumber
rvm:
- 2.3.1
- docker-compose run -e "RAILS_ENV=test" web rake db:test:prepare spec cucumber
48 changes: 26 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,39 @@
## Setting Up Development Environment

### 1 Fork and clone the repository.
https://help.github.com/articles/fork-a-repo/

### 2 Install Vagrant.
https://www.vagrantup.com/downloads.html
### 2 Install Docker.
https://docs.docker.com/install/

### 3 Install VirtualBox
https://www.virtualbox.org/wiki/Downloads
### 3 Build the Docker Container
Build the container
```
docker-compose build
```

### 4 Capture the powers of vagrant
* In the repo dir: <code>vagrant up</code> (Safely ignore: 'dpkg-preconfigure: unable to re-open stdin: No such file or directory')
* If changes have been made since running vagrant up: <code>vagrant provision</code>

* Start the rails server. There are two ways to do this, depending on your familiarity running from within the vagrant shell:
### 4 Run the Docker Container

1. A local `rake` wrapper that allows direct execution on the machine.
* Run `rake vagrant:shell[command]`<sup>1</sup>
* To start the rails server using the rake wrapper use: `rake vagrant:shell['rails s -b 0.0.0.0']`.
* Navigate to `localhost:3000`
2. Using `vagrant ssh` to gain access directly to the machine.
* To login to the machine: <code>vagrant ssh</code>
* `cd /vagrant/` to navigate to the refuge repo.
* To start the rails server use: `rails s -b 0.0.0.0`.
* Navigate to `localhost:3000`
You can now run and shutdown the app with:
```
docker-compose up
docker-compose down
```

[1] You can run any command locally using `rake vagrant:shell[]` and it will be executed in the repo root of the vagrant machine. You can try `rake vagrant:shell['pwd']` and see it will print the directory that the repo is in on the vagrant machine!
It will be available at localhost:3000

### 5 Optional tasks:
run <code>rake db:fix_accents</code> to clean up encoding problems in the safe2pee data. (Use <code>rake db:fix_accents[dry_run]</code> to preview the changes.)
### 5 Run the Tests
```
docker-compose run -e "RAILS_ENV=test" web rake db:test:prepare spec cucumber
```

### 6 Assets
### 6 Optional tasks:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkwidmer do we need this anymore? I feel if we do, it might not belong in this doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we still need this. The seed has been reduced to a small sample set rather than a larger set that it used to be. So we may not need this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to delete since in my past 3.5 years of working on this I've never done this. It might just be confusing to a newcomer

To clean up encoding problems in the safe2pee data, run (Use `rake db:fix_accents[dry_run]` to preview the changes.):
```
docker-compose run rake db:fixaccents
```

### 7 Assets
* [Assets Repo](https://github.com/RefugeRestrooms/refuge_assets)

## Testing
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
ENV PHANTOM_JS=2.1.1
RUN apt-get update && \
apt-get install build-essential chrpath libssl-dev libxft-dev -y && \
apt-get install libfreetype6 libfreetype6-dev -y && \
apt-get install libfontconfig1 libfontconfig1-dev -y && \
cd ~ && \
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" && \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just reminding myself this should be $PANTOM_JS not 2.1.1

wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2 && \
tar xvjf $PHANTOM_JS.tar.bz2 && \
mv $PHANTOM_JS /usr/local/share && \
ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin
RUN mkdir /refugerestrooms
WORKDIR /refugerestrooms
COPY Gemfile /refugerestrooms/Gemfile
COPY Gemfile.lock /refugerestrooms/Gemfile.lock
RUN bundle install
COPY . /refugerestrooms
3 changes: 0 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ require File.expand_path('../config/application', __FILE__)

SaferstallsRails::Application.load_tasks

Dir.glob('.rake/*.rb').each do |f|
import f
end
54 changes: 0 additions & 54 deletions Vagrantfile

This file was deleted.

18 changes: 11 additions & 7 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
development:
default: &default
adapter: postgresql
encoding: unicode
database: bathrooms_development
host: db
username: postgres
password:
pool: 5
host: localhost

development:
<<: *default
database: bathrooms_development


test:
adapter: postgresql
encoding: unicode
<<: *default
database: bathrooms_test
pool: 5
host: localhost

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'
services:
db:
image: postgres
web:
build: .
entrypoint: [setup/entry]
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/refugerestrooms
ports:
- "3000:3000"
depends_on:
- db
7 changes: 7 additions & 0 deletions setup/entry
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

rake db:create
rake db:migrate

exec "$@"
99 changes: 0 additions & 99 deletions setup/pg_hba.conf

This file was deleted.

Loading