Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
Added docker-compose and updated README (#37)
Browse files Browse the repository at this point in the history
* Added docker-compose and updated README
  • Loading branch information
de-code committed Apr 20, 2018
1 parent 63ebbe2 commit 7bee4b6
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .env
@@ -1 +1,4 @@
COMPOSE_PROJECT_NAME=sciencebeam
IMAGE_TAG=develop
SCIENCEBEAM_GYM_COMMIT=851eb577398d47189dff748d36a735dcc84f3adb
GROBID_TAG=0.5.1
24 changes: 23 additions & 1 deletion README.md
Expand Up @@ -11,7 +11,11 @@ You might also be interested in the [ScienceBeam Gym](https://github.com/elifesc

## Status

This is in a very early status and may change significantly. The Pipeline may not currently run successfully in the Cloud.
This is in a very early status and may change significantly.

## Docker

Note: If you just want to use the API, you could make use of the [docker image](doc/Docker.md).

## Pre-requisites

Expand Down Expand Up @@ -114,6 +118,24 @@ python -m sciencebeam.examples.conversion_pipeline --help
You can use the [grobid_service_pdf_to_xml.py](sciencebeam/examples/grobid_service_pdf_to_xml.py) or
[conversion_pipeline.py](sciencebeam/examples/conversion_pipeline.py) example as a template and add your own steps.

## API Server

The [API](doc/API.md) server is currently available in combination with GROBID.

To start the GROBID run:

```bash
docker run -p 8070:8070 lfoppiano/grobid:0.5.1
```

To start the ScienceBeam server run:

```bash
./server.sh --host=0.0.0.0 --port=8075 --grobid-url http://localhost:8070/api
```

The [ScienceBeam API](doc/API.md) will be available on port _8075_.

## Tests

Unit tests are written using [pytest](https://docs.pytest.org/). Run for example `pytest` or `pytest-watch`.
Expand Down
38 changes: 38 additions & 0 deletions doc/API.md
@@ -0,0 +1,38 @@
# ScienceBeam API

## /api/convert

The currently the only API is _/api/convert_
e.g. [http://localhost:8075/api/convert](http://localhost:8075/api/convert).

It supports three modes of use.

### GET

A GET request will show a very simple submission form that allows the user to select a file which will be submitted to the API.

### POST PDF as data

The PDF can be posted as data to the API. The API will respond with the JATS XML.

e.g.

```bash
curl -X POST --show-error -H "Content-Type: application/pdf" \
--data-binary @test.pdf \
http://localhost:8075/api/convert?filename=test.pdf
```

The _filename_ parameter is optional.

### POST PDF as a file

The PDF can also be posted as a file. The effect will be the same as posting it as data.

e.g.

```bash
curl -X POST --show-error --form \
"file=@test.pdf;filename=test.pdf" \
http://localhost:8075/api/convert
```
50 changes: 50 additions & 0 deletions doc/Docker.md
@@ -0,0 +1,50 @@
# ScienceBeam Docker Containers

This section details using or building the docker images. You will need [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/).

## Run Latest Docker Container

Clone this repository and run:

```bash
docker-compose -f docker-compose.latest.yml up
```

That will start GROBID and ScienceBeam docker containers. The [ScienceBeam API](API.md) will be available on port _8075_.

Alternatively run:

```bash
docker run --rm -p 8070:8070 lfoppiano/grobid:0.5.1
```

and:

```bash
docker run --rm -i -t -p 8075:8075 elifesciences/sciencebeam \
./server.sh --host=0.0.0.0 --port=8075 --grobid-url http://localhost:8070/api
```

## Build and Run Docker Container with Docker Compose

```bash
docker-compose -f docker-compose.yml build
```

```bash
docker-compose -f docker-compose.yml up
```

That will start GROBID and ScienceBeam docker containers. The [ScienceBeam API](API.md) will be available on port _8075_.

## Build Docker Container Only

```bash
./build_container.sh
```

## GROBID and Crossref Consolidation

GROBID is optionally using Crossref consolidation to make the results more useful for archiving.

For this project, the preference is not to enable it and the _docker-compose.yml*_ files explictly use a local network to prevent that.
29 changes: 29 additions & 0 deletions docker-compose.latest.yml
@@ -0,0 +1,29 @@
version: '3'

services:
sciencebeam:
image: elifesciences/sciencebeam:latest
command: ./server.sh \
--host=0.0.0.0 --port=8075 \
--grobid-url http://grobid:8070/api
ports:
- "8075:8075"
networks:
- default
- grobid
depends_on:
- grobid
grobid:
image: lfoppiano/grobid:${GROBID_TAG}
environment:
- JAVA_OPTS=-Xmx1g
ports:
- "8070:8070"
networks:
- grobid

networks:
default:
internal: false
grobid:
internal: true
34 changes: 34 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,34 @@
version: '3'

services:
sciencebeam:
build:
context: .
dockerfile: Dockerfile
args:
sciencebeam_gym_commit: ${SCIENCEBEAM_GYM_COMMIT}
image: elifesciences/sciencebeam:${IMAGE_TAG}
command: ./server.sh \
--host=0.0.0.0 --port=8075 \
--grobid-url http://grobid:8070/api
ports:
- "8075:8075"
networks:
- default
- grobid
depends_on:
- grobid
grobid:
image: lfoppiano/grobid:${GROBID_TAG}
environment:
- JAVA_OPTS=-Xmx1g
ports:
- "8070:8070"
networks:
- grobid

networks:
default:
internal: false
grobid:
internal: true

0 comments on commit 7bee4b6

Please sign in to comment.