A starter project using Python, FastAPI and uv.
- fastapi-uv-starter
A project starter for personal usage containing the following:
- Python 3.13.*
- FastAPI web framework
- Structured logging using
structlog
- Dependency management using
uv
- Containerisation using a Dockerfile
- Testing with
pytest
and optionally with coverage withpytest-cov
- Linting/formatting using
ruff
.gitignore
MacOS (using brew
)
brew install [email protected] uv
Ubuntu/Debian
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.13
curl -LsSf https://astral.sh/uv/install.sh | sh
From the root of the project execute:
uv sync
uv run fastapi dev
uv run fastapi run
uv run pytest
uv run pytest --cov=app
uv run pytest --cov-report html --cov=app
uv run ruff check app/* tests/*
uv run ruff format app/* tests/*
The following podman
commands are direct replacements of the Docker CLI. You can see that their syntax is identical:
podman image build -t fastapi-uv-starter .
Run our FastAPI application and map our local port 8000
to 80
on the running container:
podman container run -d --name fastapi-uv-starter -p 8000:80 --network bridge fastapi-uv-starter
podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78586e5b4683 localhost/fastapi-uv-starter:latest uvicorn main:app ... 13 minutes ago Up 5 minutes ago 0.0.0.0:8000->80/tcp nifty_roentgen
Our FastAPI server now runs on port 8000
on our local machine. We can test it with:
curl -i http://localhost:8000/healthcheck
Output:
HTTP/1.1 200 OK
server: uvicorn
content-length: 0