diff --git a/.env.example b/.env.example index 1a409ce..69018db 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ MONGO_URL=mongodb://localhost:27017/ DATABASE_NAME=your_database_name -USERNAME_NAME= +USERNAME= PASSWORD= \ No newline at end of file diff --git a/README.md b/README.md index c4d6e1c..c12a300 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,28 @@ -## FastAPI MicroService with Docker, Nginx and MongoDB(Motor) +## FastAPI Micro Service with Docker, Nginx, and Asynchronous MongoDB (Motor) -### Installation Instruction -- Create [virtual environment](https://docs.python.org/3/library/venv.html) and install requirements +### Installation Instructions + +- Create a [virtual environment](https://docs.python.org/3/library/venv.html) +- Install the python Dependencies with `pip install -r requirements.txt` +- Copy the .env.example file as .env + ```sh + cp .env.example .env + ``` +- Ensure that you fill in all the valid environment properties in the .env file. + + +### Run Locally +To run the service locally, use the following command: ```sh - pip install -r requirements.txt + uvicorn server:app --reload ``` -- Copy .env.example as .env + +### Run with Docker +To run the service using Docker, use the following command: ```sh - cp .env.example .env + sudo docker-compose up -d --build ``` -### Run docker compose -- Make sure [docker](https://docs.docker.com/engine/install) and [docker-compose](https://docs.docker.com/compose/install/) installed -### Lets Run with Docker -- Docker run `sudo docker-compose up -d --build` -- Locally run `uvicorn src.servers.start:app --reload` +### Run Docker Compose for Production Build +Ensure that you have [Docker]((https://docs.docker.com/engine/install)) and [Docker Compose](https://docs.docker.com/compose/install/) installed. -### Lets Run Locally -- Locally run `uvicorn server:app --reload` diff --git a/docker-compose.yml b/docker-compose.yml index ce69d6c..d93faa9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,14 +14,14 @@ services: - servernet server: - container_name: service + container_name: core_server build: . restart: always command: gunicorn -w 4 -k uvicorn.workers.UvicornWorker server:app --bind 0.0.0.0:8000 expose: - 8000 - # env_file: - # - .env + env_file: + - .env depends_on: - db links: diff --git a/src/servers/models/todo.py b/src/servers/models/todo.py index 2072df0..a436d59 100644 --- a/src/servers/models/todo.py +++ b/src/servers/models/todo.py @@ -6,7 +6,7 @@ class Todos(Repository): # async def index(self, add): - # await add([('', "")]) + # await add([('_id')]) def collection(self): return 'todos'