From 4e469fb9ebc6c107d3eff3b19fd6f9023bfabaad Mon Sep 17 00:00:00 2001
From: Fabian Rausch <fabian.rausch@pwc.com>
Date: Fri, 23 Oct 2020 18:08:47 +0200
Subject: [PATCH] Dockerized and documented

---
 Dockerfile       | 12 ++++++++++++
 README.md        | 15 +++++++++++++++
 deepl_api.py     |  2 +-
 requirements.txt |  2 ++
 4 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 Dockerfile
 create mode 100644 README.md
 create mode 100644 requirements.txt

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..1e38c59
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM python:3.8-buster
+
+COPY requirements.txt requirements.txt
+RUN pip install -r requirements.txt
+
+COPY auth_key auth_key
+COPY deepl_api.py deepl_api.py
+
+EXPOSE 5000
+
+ENTRYPOINT ["python"]
+CMD ["deepl_api.py"]
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1be85af
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# DeepL API
+This service receives a string to translate and returns the translation in the desired language.
+
+This service is part of the [Related Items project](https://gitlab.rrz.uni-hamburg.de/bay1620/wilps-related-items/).
+
+## Local Setup from repository
+Due to the secret AUTH KEY there is no possibility here to use an image from Docker Hub. You have to follow these instructions instead:
+- Create a file named 'auth_key' in this folder
+- Put your AUTH KEY from DeepL Pro into the file (nothing else)
+- Build the Docker image from this folder: `docker build -t deepl-api .`
+- Run the Docker container: `docker run -p 6061:5050 deepl-api`
+
+## Usage
+You can use them - for example using curl - as follows:
+- `curl -F text="Guten Abend" -F target_lang=EN -X POST http://0.0.0.0:5050/translate`
diff --git a/deepl_api.py b/deepl_api.py
index 44be8cc..d0ddccd 100644
--- a/deepl_api.py
+++ b/deepl_api.py
@@ -21,4 +21,4 @@ def get_abstracts_for_query_srf_api():
     return get_translation(text, target_lang)
 
 app.config['JSON_AS_ASCII'] = False
-app.run(host="0.0.0.0", port=int("6061"), debug=True)
\ No newline at end of file
+app.run(host="0.0.0.0", port=int("5050"), debug=True)
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..a50db1c
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+requests
+flask
-- 
GitLab