From 2a564226a3580a8cdc98d2fab3ba5bb7655a16fb Mon Sep 17 00:00:00 2001
From: Christian Boettcher <c.boettcher@fz-juelich.de>
Date: Tue, 8 Jun 2021 14:12:24 +0200
Subject: [PATCH] new and smaller dockerfile

---
 README.md            |  2 +-
 apiserver/Dockerfile | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 27b54ca..2db9fbf 100644
--- a/README.md
+++ b/README.md
@@ -98,7 +98,7 @@ while in the project root directory.
 
 To run the docker image in a local container, run 
 ```bash
-docker run -d --name <container name> -p 127.0.0.1:<local_port>:80 datacalog-apiserver
+docker run -d --name <container name> -p 127.0.0.1:<local_port>:8000 datacalog-apiserver
 ```
 
 `<container name>` is the name of your container, that can be used to refer to it with other docker commands.
diff --git a/apiserver/Dockerfile b/apiserver/Dockerfile
index 09150a9..6b91b4c 100644
--- a/apiserver/Dockerfile
+++ b/apiserver/Dockerfile
@@ -1,20 +1,24 @@
-FROM tiangolo/uvicorn-gunicorn:python3.8
+FROM python:3.9-slim
 
 LABEL maintainer="Christian Böttcher <c.boettcher@fz-juelich.de>"
+EXPOSE 8000
 
 RUN mkdir -p /app/data
 RUN mkdir -p /app/apiserver
 
-RUN apt update && apt upgrade -y
-
-RUN pip install --no-cache-dir fastapi
+RUN pip install "fastapi==0.63.0" \
+"requests==2.25.1" \
+"uvicorn==0.13.4" \
+"python-dotenv==0.17.1" \
+"python-multipart==0.0.5" \
+"python-jose[cryptography]==3.2.0" \
+"passlib[bcrypt]==1.7.4"
 
 ADD . /app/apiserver
-COPY ./config.env /app/apiserver/config.env
-
-# This RUN creates a python file that contains the fastapi app, in a location that is expected by the base docker image
-# This avoids naming conflicts with the packages in the project folder
-RUN echo "from apiserver.main import app" > /app/main.py
 
 # set data directory properly for the docker container
-RUN sed -i 's_./app/data_/app/data_g' /app/apiserver/config.env
\ No newline at end of file
+RUN sed -i 's_./app/data_/app/data_g' /app/apiserver/config.env && sed -i 's_./app/userdb.json_/app/userdb.json_g' /app/apiserver/config.env
+
+WORKDIR /app
+
+ENTRYPOINT ["uvicorn", "--host", "0.0.0.0", "apiserver:app"]
\ No newline at end of file
-- 
GitLab