diff --git a/README.md b/README.md index a4450cde512ec623e992a77793d6e4f54880dcc0..8addbee127ca47c65f0619dfdeca22db3342bff3 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,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 built -t datacatalog-apiserver ./apiserver +docker build -t datacatalog-apiserver ./apiserver ``` while in the project root directory. diff --git a/apiserver/.dockerignore b/apiserver/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..26d6acc6d0fa7bb142ccd748313a75735d92980e --- /dev/null +++ b/apiserver/.dockerignore @@ -0,0 +1,5 @@ +**/__pycache__ +**/.pytest_cache +README.md +Dockerfile +.dockerignore \ No newline at end of file diff --git a/apiserver/Dockerfile b/apiserver/Dockerfile index 80fba08926a89fdd448746c30d633e005c7d75be..09150a934b81e899f080c48baa897db43dd199f4 100644 --- a/apiserver/Dockerfile +++ b/apiserver/Dockerfile @@ -2,15 +2,19 @@ FROM tiangolo/uvicorn-gunicorn:python3.8 LABEL maintainer="Christian Böttcher <c.boettcher@fz-juelich.de>" -RUN mkdir -p /app/app/data -RUN mkdir -p /app/app/storage +RUN mkdir -p /app/data +RUN mkdir -p /app/apiserver RUN apt update && apt upgrade -y RUN pip install --no-cache-dir fastapi -COPY ./__init__.py /app/app/ -COPY ./main.py /app/app/ -COPY ./storage/JsonFileStorageAdapter.py /app/app/storage/ -COPY ./storage/LocationStorage.py /app/app/storage/ -COPY ./storage/__init__.py /app/app/storage/ \ No newline at end of file +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 diff --git a/config.env b/apiserver/config.env similarity index 73% rename from config.env rename to apiserver/config.env index 2eda1243a69540c94fffa6c98d526e81866c90c5..ee76c5c0f0c5e4903045729dab1022774c6ed565 100644 --- a/config.env +++ b/apiserver/config.env @@ -1,4 +1,4 @@ # contains Settings that can be loaded via pydantic settings .env support # DATACATALOG_APISERVER_HOST="0.0.0.0", # DATACATALOG_APISERVER_PORT=80 -DATACATALOG_APISERVER_JSON_STORAGE_PATH="./app/data" \ No newline at end of file +DATACATALOG_APISERVER_JSON_STORAGE_PATH="./app/data" diff --git a/apiserver/config/settings.py b/apiserver/config/settings.py index 6cc526ddca7e3b2be4f9d59f61b9644994ad9f3e..336c89dcea87ccdae1b30c0efea11dc8e7275211 100644 --- a/apiserver/config/settings.py +++ b/apiserver/config/settings.py @@ -10,4 +10,4 @@ class ApiserverSettings(BaseSettings): class Config: env_prefix: str = "datacatalog_apiserver_" - env_file: str = "config.env" \ No newline at end of file + env_file: str = "apiserver/config.env" \ No newline at end of file diff --git a/apiserver/main.py b/apiserver/main.py index 9366ebf2a0495e3d946d1bda72bdd7301b240f43..0be808c02741406f1f72d1ea702f3fb7e59fa089 100644 --- a/apiserver/main.py +++ b/apiserver/main.py @@ -19,7 +19,7 @@ from enum import Enum settings = ApiserverSettings() app = FastAPI( - title="API-Server for the Data Catalogue" + title="API-Server for the Data Catalog" ) adapter: AbstractLocationDataStorageAdapter = JsonFileStorageAdapter(settings)