FastAPI with PostgreSQL Part 1

We continue with the FastAPI Series and this time we are going to connect our application to a PostgreSQL Database, we are also going to do a couple of tests with Pytest, all this on Docker to have the necessary infrastructure, so, in short, we will see:

  • API Dockerization.
  • Infrastructure with Docker Compose. (DB — API)
  • SQLModel for tables.
  • Connection with PostgreSQL.
  • Testing with Pytest.

The first thing we are going to do is clone our previous Project and we are going to Dockerize it, for this, we are going to do it in the simplest way possible, in future chapters we will do it multi-staging so that it gets closer to a Production image.

First of all, we are going to create our Dockerfile file where we are going to indicate the Python image that we are going to use and we will install the dependencies through Poetry.

Click Here