A simple FastAPI template.
- FastAPI
- Pydantic
- Docker & Docker Compose
- Tests
- Docker
- Make
- uv
-
Create
.env
by copying.env.template
cp .env.template .env
-
Run the project
make dev
The app will be launched on port 8000
and it's possible to view the API docs on http://localhost:8000/docs
There's a makefile that has multiple useful commands defined within it
make dev
- runs the backend containermake build
- builds the backend containermake prod
- runs a prod version of the container that's smallermake shell
- runs and attached to the backend containermake check
- formats and checks the codemake test
- runs tests and shows the total code coverage
Command to connect to any running container:
docker exec -it <container_id> bash
Pre-commit hooks are set up to check the code on commits - configuration file. To install pre-commit hooks run pre-commit install
. More info here.
To run the checks before committing, run:
pre-commit run
after adding a dependency with uv it's necessary to rebuild the backend docker container to update the containers dependencies
make build
To build a small docker image for prod run:
make prod