From 3d9c9f4a6468fc8b68a7f203dc945af837102435 Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 23 Jan 2016 20:31:40 +0100 Subject: [PATCH 1/5] gitignore .vagrant dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9d0c400..ea86fec 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /tmp config/morph.yml /coverage +.vagrant From 10de75f6f3288e9e8588af66e9f0c7c307c0c51a Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 23 Jan 2016 20:32:22 +0100 Subject: [PATCH 2/5] Configure Elasticsearch URL via ENV --- config/initializers/elasticsearch_config.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config/initializers/elasticsearch_config.rb diff --git a/config/initializers/elasticsearch_config.rb b/config/initializers/elasticsearch_config.rb new file mode 100644 index 0000000..67d8dc3 --- /dev/null +++ b/config/initializers/elasticsearch_config.rb @@ -0,0 +1,4 @@ +config = { + host: ENV.fetch('ELASTICSEARCH_URL', 'http://localhost:9200') +} +Elasticsearch::Model.client = Elasticsearch::Client.new(config) From 0a702a18be5f7d500d5aee6e93fababdb24e9bca Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 23 Jan 2016 20:32:37 +0100 Subject: [PATCH 3/5] Add rake task to rebuild paper index --- lib/tasks/index.rake | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lib/tasks/index.rake diff --git a/lib/tasks/index.rake b/lib/tasks/index.rake new file mode 100644 index 0000000..9c66fbb --- /dev/null +++ b/lib/tasks/index.rake @@ -0,0 +1,6 @@ +namespace :index do + desc 'Rebuild elasticsearch index for Paper model' + task rebuild: :environment do + Paper.reset_index! + end +end From 1b60c08e9f93dfcba2d59ada12755b904173cdba Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 23 Jan 2016 20:33:02 +0100 Subject: [PATCH 4/5] Add Dockerfile and docker-compose config --- .dockerignore | 5 +++++ Dockerfile | 15 +++++++++++++++ docker-compose.yml | 12 ++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..09bd021 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +tmp +log +.vagrant +.git +coverage diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..827eaab --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..767a382 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +web: + build: . + volumes: + - .:/app + ports: + - "3000:3000" + links: + - elasticsearch + environment: + ELASTICSEARCH_URL: 'http://elasticsearch:9200' +elasticsearch: + image: elasticsearch:1.7 From a3ac746ac00dc308fd3822969557a101ce4eeeb4 Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 23 Jan 2016 20:33:08 +0100 Subject: [PATCH 5/5] Update README --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 29bc41a..45ec875 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,13 @@ 1. Start Rails server: `bundle exec rails s` 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://:3000' ## Adding a data source (web scraper) Example scraper: https://morph.io/ahx/city_council_leipzig_recent_papers