From 73612701ce9281659d43ef647847ce31af03fc34 Mon Sep 17 00:00:00 2001 From: Steve Wainstead Date: Sun, 30 May 2021 08:52:49 -0400 Subject: [PATCH 1/2] Containerize the project; use uvicorn to invoke Containerizing got around a pandas compilation issue I was having locally. Using uvicorn got the server running, whereas running it via "python wsgi.py" just exited with a status of zero. --- Dockerfile | 10 ++++++++++ docker-compose.yml | 6 ++++++ requirements.txt | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..59cf5d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.9.5-alpine3.13 +WORKDIR /code +ENV FASTAPI_APP=app.py +ENV FASTAPI_RUN_HOST=0.0.0.0 +RUN apk add --no-cache gcc musl-dev linux-headers make +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt +EXPOSE 5000 +COPY . . +CMD ["python", "wsgi.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d748397 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: "3.9" +services: + web: + build: . + ports: + - "5000:5000" diff --git a/requirements.txt b/requirements.txt index e196401..845cdec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,22 @@ +aiofiles==0.7.0 +aniso8601==7.0.0 appdirs==1.4.4 astroid==2.4.2 +async-exit-stack==1.0.1 +async-generator==1.10 attrs==19.3.0 black==19.10b0 certifi==2020.6.20 chardet==3.0.4 click==7.1.2 +dnspython==2.1.0 +email-validator==1.1.2 fastapi==0.58.1 Flask==1.1.2 +Flask-SQLAlchemy==2.5.1 +graphene==2.1.8 +graphql-core==2.3.2 +graphql-relay==2.0.1 h11==0.9.0 httptools==0.1.1 idna==2.10 @@ -21,9 +31,13 @@ mccabe==0.6.1 more-itertools==8.4.0 mypy==0.782 mypy-extensions==0.4.3 +numpy==1.20.3 +orjson==3.5.2 packaging==20.4 +pandas==1.2.4 pathspec==0.8.0 pluggy==0.13.1 +promise==2.3 py==1.9.0 pydantic==1.5.1 pyhumps==1.3.1 @@ -31,14 +45,20 @@ pylint==2.5.3 pyparsing==2.4.7 pytest==5.4.3 pytest-asyncio==0.14.0 +python-dateutil==2.8.1 +python-multipart==0.0.5 +pytz==2021.1 +PyYAML==5.4.1 regex==2020.6.8 requests==2.24.0 +Rx==1.6.1 six==1.15.0 SQLAlchemy==1.3.18 starlette==0.13.4 toml==0.10.1 typed-ast==1.4.1 typing-extensions==3.7.4.2 +ujson==4.0.2 urllib3==1.25.9 uvicorn==0.11.5 uvloop==0.14.0 From 0c7d6ac07482fec97991e97df4f232352c1f6ba1 Mon Sep 17 00:00:00 2001 From: Steve Wainstead Date: Sun, 30 May 2021 08:55:34 -0400 Subject: [PATCH 2/2] Update the README.md --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 36c2ffa..4f935e8 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,11 @@ Type "Y" to accept the message (which is just there to prevent you accidentally Finally run the app with ``` -python wsgi.py +uvicorn wsgi.py ``` -Navigate to the posted URL in your terminal to be greeted with Swagger, where you can test out the API. +Navigate to http://127.0.0.1:8000/docs to be greeted with Swagger, +where you can test out the API. @@ -52,3 +53,9 @@ pip install pytest pytest ``` +## Running via docker-compose +``` +docker-compose up + +``` +