diff --git a/README.md b/README.md index 88f16a3c38793c122284df796be94634c4faaf15..d61686c05bb93a25e717276407fc8e5badc67a69 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ The `context.py` file helps with importing the apiserver-packages, so that the t To build the docker image of the current version, simply run ```bash -docker build -t datacatalog-apiserver ./apiserver +docker build -t datacatalog-apiserver -f ./apiserver/Dockerfile . ``` while in the project root directory. @@ -101,13 +101,18 @@ 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>:8000 datacalog-apiserver +docker run -d --name <container_name> -p <local_port>:8000 datacatalog-apiserver ``` -`<container name>` is the name of your container, that can be used to refer to it with other docker commands. +`<container_name>` is the name of your container, that can be used to refer to it with other docker commands. `<local_port>` is the port of your local machine, which will be forwarded to the docker container. For example, if it is set to `8080`, you will be able to reach the api-server at http://localhost:8080. +For more production ready deployments consider using `--restart=always` flag, as well as inject path for data: +```bash +docker run -d --name <container_name> --restart=always -v /localvol/:/app/data/ -p <local_port>:8000 datacatalog-apiserver +``` + #### Stopping the docker image To stop the docker image, run diff --git a/apiserver/Dockerfile b/apiserver/Dockerfile index 6b91b4c5783bca92efbb8c9574d663f2e4cceacb..ca2c039f48ab2e10406abad68d7a889302e10ff5 100644 --- a/apiserver/Dockerfile +++ b/apiserver/Dockerfile @@ -1,24 +1,11 @@ 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 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 - +VOLUME /app/data +ADD ./apiserver/ /app/apiserver +ADD ./requirements.txt /app/apiserver/requirements.txt +RUN python3 -m pip install --no-cache-dir -r /app/apiserver/requirements.txt # set data directory properly for the docker container 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