febus982 / bootstrap-python-fastapi

A python service built using Clean Architecture and SOLID principles
https://febus982.github.io/bootstrap-python-fastapi
37 stars 2 forks source link
alembic clean-architecture fastapi grpc python software-architecture sqlalchemy template template-repository template-repository-python

Bootstrap python service

CI Pipeline Python tests Test Coverage Maintainability

Checked with mypy Ruff Code style: black security: bandit

This is an example implementation of a python application applying concepts from Clean Architecture and SOLID principles.

This template provides out of the box some commonly used functionalities:

Documentation

The detailed documentation is available:

How to use

Create your GitHub repository using this template (The big green Use this template button). Optionally tweak name and authors in the pyproject.toml file, however the metadata are not used when building the application, nor are referenced anywhere in the code.

Using Docker:

Locally:

Other commands for development

Multistage dockerfile configuration

Python docker image tend to become large after installing the application requirements (the slim base is ~150 MB uncompressed), therefore it's important to spend efforts to minimise the image size, even if it produces a slightly more complex multistage Dockerfile.

The following setup makes sure the production image will keep to a minimal size ("only" 390MB):

Using the following pipeline the "test" image is instead ~850MB, more than 400MB that would end up as a cost in traffic on each image pull.