{"repo":"zhanymkanov/fastapi_production_template","free":true,"listed":false,"github":"https://github.com/zhanymkanov/fastapi_production_template","clone":"git clone https://github.com/zhanymkanov/fastapi_production_template.git","description":"FastAPI Template with Docker, Postgres","language":"Python","stars":1257,"topics":["fastapi"],"license":"Unlicense","category":"deployment-docker-iac","readme_excerpt":"FastAPI Template This repo is kind of a template I use when starting up new FastAPI projects: - easy local development - environment with configured postgres - script to lint code with ruff and ruff format - SQLAlchemy with slightly configured alembic - async SQLAlchemy engine - pessimistic connection pooling configuration (link) - migrations set in easy to sort format ( YYYY-MM-DD slug ) - migrations are formated with ruff - global pydantic model with - explicit timezone setting during JSON export - some configs for production - gunicorn with dynamic workers configuration (stolen from @tiangolo) - Dockerfile optimized for small size and fast builds with a non-root user - JSON logs - sentry for deployed envs - and some other extras like global exceptions, sqlalchemy keys naming convention, shortcut scripts for alembic, etc. Local Development Setup just MacOS: Debian/Ubuntu: Others: link Setup poetry Other ways: link Setup Postgres (16.3) Copy the environment file and install dependencies 1. cp .env.example .env 2. poetry install Run the uvicorn server With default settings: With extra configs (e.g. logging file) Linters Format the code with ruff --fix and ruff format Migrations - Create an automatic migration from changes in src/database.py - Run migrations - Downgrade migrations Deployment Deployment is done with Docker and Gunicorn. The Dockerfile is optimized for small size and fast builds with a non-root user. The gunicorn configuration is set to use the number of workers","default_branch":null,"files":null,"tree":[],"storefront":"/r/zhanymkanov","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/zhanymkanov/fastapi_production_template/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}