Commit 5376cae3 authored by Mischa Buchhofer's avatar Mischa Buchhofer Committed by Patrick Schlindwein
Browse files

Feat/#59 add docker containers

parent bcca6a60
......@@ -10,4 +10,5 @@ src/ktor-server/.idea/misc.xml
.DS_Store
.idea/
.gradle/
src/mongodb_data/
src/nltk_data/
### Docker based Setup
Use the following command to start all containers (First run takes a lot of time):
docker-compose up --build
Afterwards the following services are available:
* Port 8080: ktor-server
* Port 8000: nlp_server
* Port 27017: MongoDB-Server
To access the OpenAPI documentation of nlp_server open **http://localhost:8080/docs**.
The following paths are mounted by default:
* nltk_data: to store nltk-data, e.g. big models, which we don't want to download every time we start our container.
* mongodb_data: stores the data of the mongodb container.
version: "3.7"
services:
python_nlp:
build: nlp
ports:
- 8000:8000
volumes:
- ./nltk_data:/usr/share/nltk_data
ktor-server:
build: ktor-server
ports:
- 8080:8080
openapi_validator:
build: docker-openapi-validator
environment:
WAIT_HOSTS: python_nlp:8000, ktor-server:8080
WAIT_TIMEOUT: 3600
WAIT_HOSTS_TIMEOUT: 3600
WAIT_SLEEP_INTERVAL: 5
depends_on:
- python_nlp
- ktor-server
mongodb_container:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
ports:
- 27017:27017
volumes:
- ./mongodb_data:/data/db
FROM node:15.14-alpine3.13
# ARG is used here to make auto-update easy
ARG version=0.46.0
RUN npm install -g ibm-openapi-validator@${version}
RUN apk add --no-cache wget
COPY ./entrypoint.sh /
# create lint-openapi config
RUN lint-openapi init
# download docker-compose-wait
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait
## Launch the wait tool and then your application
CMD /wait && /entrypoint.sh
#!/bin/sh
wget "http://python_nlp:8000/openapi.json"
#wget "http://ktor-server:8080/openapi.yml"
echo "####### Linting nlp_server OpenAPI.json #######"
lint-openapi ./openapi.json
#lint-openapi ./openapi.yml
FROM gradle:7.0.2-jdk11 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle clean installDist --no-daemon
EXPOSE 8080
WORKDIR /home/gradle/src/build/install/ktor-server/bin
CMD ./ktor-server
FROM python:3.9.4
EXPOSE 8000
# Install Debian and PyPi packages
RUN apt-get update && apt-get install -y gcc python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev g++
COPY ./requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Copy app directory to container
COPY ./app /app
# RUN pip install fastapi uvicorn
# Run tests
# RUN python -m unittest /app/tests/test*
# Install and run linter
RUN pip install --no-input flake8
RUN python -m flake8 --extend-exclude venv ./app
# Start server
RUN pip install fastapi uvicorn
CMD ["uvicorn", "app.nlp_server:app", "--host", "0.0.0.0", "--port", "8000"]
# NLP with Python
## setup
## Setup
### Docker based Setup
Use the following command to start all containers (First run takes a lot of time):
docker-compose up --build
Afterwards the following services are available:
* Port 8080: ktor-server
* Port 8000: nlp_server
* Port 27017: MongoDB-Server
To access the OpenAPI documentation of nlp_server open **http://localhost:8080/docs**.
The following paths are mounted by default:
* nltk_data: to store nltk-data, e.g. big models, which we don't want to download every time we start our container.
* mongodb_data: stores the data of the mongodb container.
### Bare metal setup
- install latest version of python and pip, tested with Python 3.9.2 and pip 21.0.1
- open command shell as **admin** and run
......@@ -69,9 +89,9 @@ The OpenAPI doc is available under http://127.0.0.1:8000/docs
- following parameter can be set:
text (string): The text that will be summarized.
max_length(int): maximum allowed amount of characters for this strategy
-Bert strategy only works with a ratio parameter inside this class. This ratio
parameter returns the ratio of sentences in the summary, which doesn't implicit
the ratio of characters in the summary. So the ratio has to be calculated and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment