A FastAPI and Apache Kafka project built in a Docker container
First of all, you need to configure your enviroment:
- Python
3.9installed - Pip
3installed - Java
8installed - Docker installed
- Docker-compose installed
git initgit remote add origin https://github.com/harlemmuniz/kafka-fastapi-docker.gitgit pull origin main
or
git initgit clone https://github.com/harlemmuniz/kafka-fastapi-docker.git
Installing Kafka and Kafdrop using docker compose in project/kafka folder:
cd /path/to/root/project/kafka
docker-compose up -d
Installing a Python virtual environment:
pip3 install virtualenv
Creating a Python virtual environment in the project root folder:
cd /path/to/root/project
virtualenv env
Activating the virtual environment:
source env/bin/activate
Installing the required libraries:
pip3 install fastapi aiokafka uvicorn
Starting the application (You should not use --reload in production.):
uvicorn main:app --reload
If you want to run the project in Google Cloud, you will need to install the gunicorn:
pip3 install gunicorn