Project with a simple Python (uv) + FastAPI + Redis + Postgres with Docker and Docker Compose.
Boilerplate to use in future projects.
Contains a Python 3.12.11 configuration with a main FastAPI entry, Pydantic Settings configuration, Postgres and Redis connection with SQLAlchemy, definition of models (with SQLAlchemy) and schemas (with pydantic) and an example of unit tests using pytest with pytest-asyncio.
Softwares installed:
- Docker 24.0+
- Docker Compose v2 or v3
Certify yourself that the Docker daemon is running in the background before running (./cmd.core.sh or docker compose up -d).
- python 3.12.11 (slim)
- uv 0.8.22
- postgres 18.1 (alpine)
- redis 7.2 (alpine)
- Docker
- Docker Compose
Additionally (compose-tools.yaml):
- pgadmin
- redis-insight
- uvicorn[standard] 0.40.0
- fastapi 0.128.0
- psycopg[binary] 3.3.2
- redis 7.1.0
- sqlalchemy 2.0.45
- pydantic 2.12.5
- pydantic-settings 2.12.0
- pytest 9.0.2
- pytest-asyncio 1.3.0
Also consider installing:
- celery[redis]
- httpx
- alembic
- flower
- Run
cmd.setup.sh - Define the
.env - Define the
database/password.txt - Verify the python packages (add, remove etc)
- Verify the
compose.yamlandcompose-tools.yaml(add, remove etc) and check the:workerservice andwebhealthcheck - Verify the
app/Dockerfile(set the CMD, change things etc)
About the worker service, it connects with:
celerypython packageapp/src/worker.pyfileworkerdefinition atcompose.yaml