Merge pull request #17 from ahx/add-docker

Add docker
This commit is contained in:
Lars Mai 2016-01-25 19:32:59 +01:00
commit b3e869da31
7 changed files with 50 additions and 1 deletions

5
.dockerignore Normal file
View file

@ -0,0 +1,5 @@
tmp
log
.vagrant
.git
coverage

1
.gitignore vendored
View file

@ -16,3 +16,4 @@
/tmp /tmp
config/morph.yml config/morph.yml
/coverage /coverage
.vagrant

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM ruby:2.2
RUN apt-get update && apt-get install -y build-essential zlib1g-dev libsqlite3-dev nodejs nodejs-legacy
RUN mkdir -p /app
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
ADD . /app
WORKDIR /app
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]

View file

@ -8,7 +8,13 @@
1. Start Rails server: `bundle exec rails s` 1. Start Rails server: `bundle exec rails s`
1. Visit [http://localhost:3000](http://localhost:3000) 1. Visit [http://localhost:3000](http://localhost:3000)
TODOs: https://github.com/ahx/stadtratmonitor/issues ### Using docker
1. Install docker and docker-compose: https://docs.docker.com/compose/install/
1. Start the app: `docker-compose up`
1. TODO db:migrate, import data, setup index
1. Get the address of the docker host: `docker-machine ip default`
1. Point your browser to: 'http://<IP of docker host>:3000'
## Adding a data source (web scraper) ## Adding a data source (web scraper)
Example scraper: https://morph.io/ahx/city_council_leipzig_recent_papers Example scraper: https://morph.io/ahx/city_council_leipzig_recent_papers

View file

@ -0,0 +1,4 @@
config = {
host: ENV.fetch('ELASTICSEARCH_URL', 'http://localhost:9200')
}
Elasticsearch::Model.client = Elasticsearch::Client.new(config)

12
docker-compose.yml Normal file
View file

@ -0,0 +1,12 @@
web:
build: .
volumes:
- .:/app
ports:
- "3000:3000"
links:
- elasticsearch
environment:
ELASTICSEARCH_URL: 'http://elasticsearch:9200'
elasticsearch:
image: elasticsearch:1.7

6
lib/tasks/index.rake Normal file
View file

@ -0,0 +1,6 @@
namespace :index do
desc 'Rebuild elasticsearch index for Paper model'
task rebuild: :environment do
Paper.reset_index!
end
end