diff --git a/README.md b/README.md index 27b54ca3aea712f9801ecaa2c9aa4d68991704fb..2db9fbf96f701133a128f25a80427dc614d572eb 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 09150a934b81e899f080c48baa897db43dd199f4..6b91b4c5783bca92efbb8c9574d663f2e4cceacb 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