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

wrapped sinatra app into a rack app & added docker-compose #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand All @@ -45,4 +53,3 @@ License
-------

Licensed under the MIT License.

3 changes: 3 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require "./server.rb"

run Server
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: {}
7 changes: 6 additions & 1 deletion server.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -188,3 +191,5 @@ def text_blocks_for_offset(run, offset, length)
content_type 'text/plain'
`pr -n -t parse.leg.c`
end

end