diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..71638cd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ruby:2.3 + +RUN git clone git://github.com/AboutUs/pegleg.git /usr/local/src/pegleg \ + && cd /usr/local/src/pegleg \ + && make \ + && make install \ + && apt-get update \ + && apt-get install -y --no-install-recommends graphviz time gdb +RUN useradd \ + --uid 1000 --gid 50 \ + --shell /bin/bash \ + --create-home --home-dir /exploratory-parsing \ + web +RUN gem install sinatra \ + && gem install haml \ + && gem install diffy +COPY . /usr/local/src/exploratory-parsing +WORKDIR /exploratory-parsing +USER web +RUN cp -R /usr/local/src/exploratory-parsing/* /exploratory-parsing/ +EXPOSE 8080 +CMD ["rackup", "--host", "0.0.0.0", "-p", "8080"] diff --git a/README.md b/README.md index 22dd19d..d00674a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,15 @@ Download sample data. Launch the server. - ruby server.rb + rackup + +Alternative Installation (Docker) +--------------------------------- + + docker-compose run --rm bootstrap + docker-compose up -d web + +Then point your web browser at: http://your-docker-host:8080/ Usage ----- @@ -45,4 +53,3 @@ License ------- Licensed under the MIT License. - diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..1f31f89 --- /dev/null +++ b/config.ru @@ -0,0 +1,3 @@ +require "./server.rb" + +run Server diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..674c64b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +# 'bootstrap' service below sets up the persistent storage used by the +# 'web' service. Adapt the bootstrap service to install other data +# sources into the /exploratory-parsing/data directory. + +version: '2' + +services: + bootstrap: + image: buildpack-deps:jessie + volumes: + - "storage:/exploratory-parsing" + - ".:/usr/local/src/exploratory-parsing" + working_dir: /exploratory-parsing + command: > + bash -c "cp -R /usr/local/src/exploratory-parsing / + && sh scripts/download_world_factbook.sh + && chown -R 1000:50 /exploratory-parsing" + web: + build: + context: . + ports: + - 8080:8080 + volumes: + - "storage:/exploratory-parsing" + +volumes: + storage: {} diff --git a/server.rb b/server.rb index d7833b9..5603982 100644 --- a/server.rb +++ b/server.rb @@ -1,10 +1,13 @@ $KCODE = "U" require 'rubygems' -require 'sinatra' +require 'sinatra/base' require 'haml' require 'fileutils' require "diffy" +class Server < Sinatra::Base + +set :bind, "0.0.0.0" set :port, 8080 enable :sessions @@ -188,3 +191,5 @@ def text_blocks_for_offset(run, offset, length) content_type 'text/plain' `pr -n -t parse.leg.c` end + +end