This repository demonstrates a production-ready Docker setup for a FastAPI application integrated with PostgreSQL and Redis.
docker version or docker info]To start the entire application stack, run:
docker compose up -d
Check the status of the containers:
docker compose ps
POST http://localhost:8000/items/?name=MyItemTo stop the services:
docker compose stop
To remove the containers and networks (retaining data):
docker compose down
To remove the containers, networks, AND database volumes:
docker compose down -v
python:3.11-slim and postgres:15-alpine as base images.postgres_data for database persistence.backend for service communication.Verification Results Automated Tests I verified the application’s functionality using curl:
FastAPI Root: Successfully returned {“message”:”FastAPI is running in Docker!”}. Redis Integration: Incremented the counter via GET /hits. PostgreSQL Integration: Successfully created and listed items via POST /items/ and GET /items/. TIP
You can visit http://localhost:8000/docs in your browser to interact with the API via Swagger UI!