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/.gitignore b/.gitignore index 9d0c400..ea86fec 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /tmp config/morph.yml /coverage +.vagrant 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/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 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) 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 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