初始化空白分支文件
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
services:
|
||||
litellm:
|
||||
image: ghcr.io/berriai/litellm:main-latest
|
||||
container_name: litellm
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./config.yaml:/app/config.yaml
|
||||
# 【关键】挂载自定义脚本到容器根目录
|
||||
- ./daily_limit.py:/app/daily_limit.py
|
||||
command:
|
||||
- "--config=/app/config.yaml"
|
||||
ports:
|
||||
- "23003:4000"
|
||||
environment:
|
||||
# ⚠️ 必须设置这个环境变量,否则 Python 找不到你的脚本
|
||||
PYTHONPATH: "/app"
|
||||
DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm"
|
||||
STORE_MODEL_IN_DB: "True"
|
||||
# --- Modified: 添加 Redis 配置 ---
|
||||
REDIS_HOST: "redis" # 对应下方 redis 服务的名字
|
||||
REDIS_PORT: "6379"
|
||||
# -------------------------------
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
- db
|
||||
- redis # --- New: 依赖 redis 启动 ---
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4000/health/liveliness')"
|
||||
interval: 300s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# --- New: 添加 Redis 服务 ---
|
||||
redis:
|
||||
image: redis:alpine # 使用 alpine 版本,体积非常小
|
||||
container_name: litellm_redis
|
||||
restart: unless-stopped
|
||||
# --maxmemory 512mb : 限制 Redis 最多使用 512MB 内存
|
||||
# --maxmemory-policy allkeys-lru : 内存满了之后,自动删除最久未使用的缓存(无论是否过期)
|
||||
# --save "" : 如果你不需要持久化缓存到硬盘(重启后清空),可以把 save 设为空,减少磁盘IO
|
||||
# command: redis-server --save 60 1 --maxmemory 128mb --maxmemory-policy allkeys-lru --loglevel warning
|
||||
command: redis-server --maxmemory 32mb --maxmemory-policy allkeys-lru --save 300 1 --loglevel warning
|
||||
# 配置详解:
|
||||
# --maxmemory 32mb: 严格限制内存使用 32MB
|
||||
# --maxmemory-policy allkeys-lru: 内存满时挤掉旧数据(安全兜底)
|
||||
# --save 300 1: 每300秒(5分钟)如果至少有1个key变化,就保存快照到磁盘 (降低IO)
|
||||
volumes:
|
||||
# 映射数据目录,确保重启容器后,今天的计数还在
|
||||
- redis_data:/data
|
||||
# ---------------------------
|
||||
|
||||
db:
|
||||
image: postgres:16
|
||||
restart: unless-stopped
|
||||
container_name: litellm_db
|
||||
environment:
|
||||
POSTGRES_DB: litellm
|
||||
POSTGRES_USER: llmproxy
|
||||
POSTGRES_PASSWORD: dbpassword9090
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -d litellm -U llmproxy"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
name: litellm_postgres_data
|
||||
redis_data: # 如果开启了 redis 持久化,这里也要打开
|
||||
driver: local
|
||||
Reference in New Issue
Block a user