Loading video player...
In this video, I'll walk you through setting up a development environment for a FastAPI application using PostgreSQL as the database, SQLAlchemy as the ORM, and Alembic for handling migrations – all running inside Docker and Docker Compose. What we cover step by step: - Creating the project structure - Writing a Dockerfile for FastAPI - Setting up PostgreSQL with persistent data - Configuring SQLAlchemy 2.0 style with async support - Adding Alembic for database migrations - Using Docker Compose to run everything together (app + db) - Hot-reloading during development SOURCE CODE: https://github.com/jod35/fastapi-postgresql-sqlalchemy-alembic-docker-template By the end, you'll have a fully working development setup that's easy to share with teammates, works the same on Windows, macOS, and Linux, and is ready for adding tests, linting, or deploying later. TIMESTAMPS: 0:00 - Introduction 1:14 - Create a FastAPI Project 4:36 - Dockerize a FastAPI app 7:30 - Introducing Docker Compose 10:50 - Defining services in Docker compose 11:39 - Set Up the API service 14:12 - Set Up the PostgreSQL service 15:05 - Set Up the PostgreSQL volume 18:43 - Run the services with Docker compose 20:03 - Install SQLAlchemy, Asyncpg and Pydantic-settings 20:55 - Manage environment variables 26:06 - Connect to PostgreSQL 36:26 - Create a sample db table 42:36 - Introducing Docker Compose Watch 43:36 - Configure Docker Compose Watch 46:22 - Run the services with Docker Compose Watch 48:30 - Introducing Alembic 49:30 - Initialize Alembic 54:41 - Configure Alembic 59:58 - Create the initial revision 1:04:49 - Apply the revision 1:05:45 - Conclusion