Sign inSign up

lucas1024/fastapi-template

By lucas1024

•Updated 4 months ago

FastAPI template. Using FastAPI, SQLModel, PostgreSQL, Redis, Celery, RabbitMQ, etc.

Image
Integration & delivery
Developer tools
Web servers
0

3.8K

lucas1024/fastapi-template repository overview

⁠fastapi-template

FastAPI template. Using FastAPI, SQLModel, PostgreSQL, Redis, Celery, RabbitMQ, Docker, GitHub Actions, automatic HTTPS and more.

⁠Features

  • Virtual Environment support: uv
  • SQL Database support: PostgreSQL
  • Caching support: Redis
  • Task Queue support: Celery
  • Message Queue support: RabbitMQ
  • Containerization support: Docker
  • Workflow support: GitHub Actions
  • Automatic HTTPS support: Automatic HTTPS

⁠System Requirements

  • Python 3.13+
  • PostgreSQL 16+
  • Redis 8.4+
  • RabbitMQ 4.2+
  • Docker Engine 29.1+
  • Automatic HTTPS

⁠Usage

⁠.env
# .env

APP_NAME="FastAPI App"
APP_VERSION=v1
APP_ROOT_URL=/api
APP_DESCRIPTION="FastAPI App description."
DEBUG=true

# SQL Database (PostgreSQL)
SQL_DB_ENABLED=true
SQL_DB_URL=postgresql+psycopg://postgres:postgres@localhost:5432/postgres
SQL_DB_CONNECT_TIMEOUT=5.0
SQL_DB_POOL_SIZE=10
SQL_DB_POOL_TIMEOUT=5.0

# Cache (Redis)
REDIS_URL=redis://:foobared@localhost:6379/0
CACHE_PREFIX=
CACHE_MAX_CONNS=4096
CACHE_CONN_TIMEOUT=3.0
CACHE_TIMEOUT=3.5

# Task (Celery with RabbitMQ/Redis)
TASK_QUEUE_BROKER=amqp://guest:guest@localhost:5672
#TASK_QUEUE_BROKER=redis://:foobared@localhost:6379/0
TASK_QUEUE_BACKEND=redis://:foobared@localhost:6379/0
TASK_TIME_LIMIT=60
TASK_QUEUE_BROKER_CONNECTION_TIMEOUT=3.0
TASK_QUEUE_BROKER_CONNECTION_MAX_RETRIES=3
TASK_QUEUE_RESULT_EXPIRES=86400

# uvicorn
UVICORN_PORT=8000
UVICORN_WORKERS=1
UVICORN_CONCURRENCY=1024
UVICORN_MAX_REQUESTS=10000
UVICORN_BACKLOG=4096
UVICORN_LOG_LEVEL=info
UVICORN_TIMEOUT_KEEP_ALIVE=5
⁠Run
docker run -d --network=host --env-file .env fastapi-template:<tag>

docker logs -f <container_id>
docker stop <container_id>
docker rm <container_id>
docker ps -a

# Run App with Celery
docker compose up -d

⁠References

Tag summary

Content type

Image

Digest

sha256:3199b54bc…

Size

105 MB

Last updated

4 months ago

docker pull lucas1024/fastapi-template