From bcd412d49a804eb00d0585dc2272d271657414c5 Mon Sep 17 00:00:00 2001 From: Michael Pisman Date: Tue, 26 Sep 2023 23:05:05 -0600 Subject: [PATCH 1/4] style: Renamed mongo database Renamed mongo database from app to unipoll-api --- src/unipoll_api/mongo_db.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/unipoll_api/mongo_db.py b/src/unipoll_api/mongo_db.py index 5b0e407..7c1a2ca 100644 --- a/src/unipoll_api/mongo_db.py +++ b/src/unipoll_api/mongo_db.py @@ -5,10 +5,11 @@ settings = get_settings() client = motor.motor_asyncio.AsyncIOMotorClient( - settings.mongodb_url, uuidRepresentation="standard" + host=settings.mongodb_url, + uuidRepresentation="standard", ) -mainDB = client.app +mainDB = client["unipoll-api"] documentModels = [ Documents.AccessToken, From 03e71a83e2ef810e9e8bbc22b13514f26426b7d0 Mon Sep 17 00:00:00 2001 From: Michael Pisman Date: Tue, 26 Sep 2023 23:06:09 -0600 Subject: [PATCH 2/4] test: Added back the testpaths field Without testpaths, pytest would rund tests from dependency modules --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 8ce7e07..f7adba8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,7 @@ max-line-length = 120 [tool.pytest.ini_options] pythonpath = ["src"] +testpaths = ["tests"] addopts = "--cov --cov-report lcov" asyncio_mode="auto" filterwarnings = [ From 0d44ba04351dd69f8a1df61af4e9f6e0511caf82 Mon Sep 17 00:00:00 2001 From: Michael Pisman Date: Sun, 1 Oct 2023 18:07:51 -0600 Subject: [PATCH 3/4] build: Changed python base image to 3.11-alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 62ea74a..f48ea9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM python:3.11-alpine WORKDIR /unipoll-api From 210452d13f37d04a57ec32e55115452fdd8f64a5 Mon Sep 17 00:00:00 2001 From: Michael Pisman Date: Sun, 1 Oct 2023 18:58:16 -0600 Subject: [PATCH 4/4] refactor: Changed Dockerfile Change build process to add unipoll-api entry point --- Dockerfile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f48ea9d..56acc1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,22 @@ FROM python:3.11-alpine WORKDIR /unipoll-api -COPY ./requirements.txt /unipoll-api/requirements.txt +COPY ./pyproject.toml /unipoll-api/pyproject.toml -RUN pip install --no-cache-dir -r /unipoll-api/requirements.txt +COPY ./src/ /unipoll-api/src/ -COPY ./src/ /unipoll-api/ +RUN pip install build -CMD ["uvicorn", "unipoll_api.app:app"] \ No newline at end of file +RUN python -m build + +FROM python:3.11-alpine + +WORKDIR /unipoll-api + +COPY --from=0 /unipoll-api/dist/*.tar.gz . + +RUN tar -xf unipoll-api-*.tar.gz --strip-components=1 + +RUN pip install . + +ENTRYPOINT [ "unipoll-api" ] \ No newline at end of file