This is very simple and quick example how to make the FastAPI app by designing in terms of CNCF
app-gugu/
├── Dockerfile
├── README.md
├── __pycache__
│ └── main.cpython-311.pyc
├── requirements.txt
├── src
│ ├── __init__.py
│ ├── __pycache__
│ ├── main.py
│ ├── model
│ └── service
└── tests
├── __pycache__
├── conftest.py
├── service
└── test_main.py
This project uses uv, If you need to install it, Use the snippet as follows.
pip install uv
And then install all dependencies by using requirements.txt
.
uv pip install -r requirements.txt
You can run the server by using uvicorn.
PYTHONPATH=$(pwd)/src uvicorn src.main:app --host 0.0.0.0 --port 8000
Building
docker build . -t fastapi_gugu:latest
Runninng
docker run -dit --name your-app -p 8000:8000 fastapi_gugu
Testing via cURL
curl localhost:8000/health
# expected result
# {"status":"ok","is_error":false,"result":null}
PYTHONPATH=$(pwd)/src pytest tests/