From f642d028e78eff248da45ecda5f664937ed2c6f2 Mon Sep 17 00:00:00 2001 From: getmoin Date: Thu, 3 Apr 2025 20:40:50 -0400 Subject: [PATCH] Updated application with Dockerfile and latest requirements versions --- Dockerfile | 8 ++++++++ README.md | 4 ++-- app/database.py | 3 +-- requirements.txt | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5641cc6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.10-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +EXPOSE 8000 +RUN touch /app/users.db +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] \ No newline at end of file diff --git a/README.md b/README.md index ca84471..67d2fcf 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ cd SimpleFastPyAPI Install the project dependencies: ```bash -pip install -r requirements.txt +docker build -t SimpleFastPyAPI . ``` Run the application: ```bash -uvicorn main:app --reload +docker run -p 8000:8000 -v $(pwd)/users.db:/app/users.db SimpleFastPyAPI ``` The application will start and be available at http://localhost:8000. diff --git a/app/database.py b/app/database.py index ef1af1c..292e947 100644 --- a/app/database.py +++ b/app/database.py @@ -1,8 +1,7 @@ from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker - -DATABASE_URL = "sqlite:///../users.db" +DATABASE_URL = "sqlite:///./users.db" engine = create_engine(DATABASE_URL) diff --git a/requirements.txt b/requirements.txt index 15f748f..f2cc1e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,9 +26,9 @@ requests==2.32.0 rfc3986==1.5.0 sniffio==1.3.0 SQLAlchemy==1.4.47 -starlette==0.40.0 +starlette==0.35.0 typing==3.7.4.3 -typing_extensions==4.5.0 +typing_extensions==4.8.0 ujson==5.7.0 urllib3==1.26.19 uvicorn==0.21.1