Spaces:
Running
Running
github-actions[bot] commited on
Commit ·
e578c35
1
Parent(s): 47f9aeb
deploy: 2c5cbbb — 更新 docker-compose.yml
Browse files- docker-compose.yml +35 -19
docker-compose.yml
CHANGED
|
@@ -8,13 +8,8 @@ services:
|
|
| 8 |
# multiple commits per day; /model/delete field names, config.yaml keys, and
|
| 9 |
# routing behaviour have all changed between minor versions without notice.
|
| 10 |
#
|
| 11 |
-
#
|
| 12 |
-
#
|
| 13 |
-
# a moving target, so for production deployments pin to a specific version:
|
| 14 |
-
# ghcr.io/berriai/litellm:main-v1.81.14-stable
|
| 15 |
-
#
|
| 16 |
-
# To upgrade: review the release notes at https://docs.litellm.ai/release_notes
|
| 17 |
-
# then bump the version below and redeploy.
|
| 18 |
image: ghcr.io/berriai/litellm:main-v1.81.14-stable
|
| 19 |
container_name: ai_gateway_litellm
|
| 20 |
restart: unless-stopped
|
|
@@ -23,14 +18,19 @@ services:
|
|
| 23 |
- litellm_data:/app/data
|
| 24 |
environment:
|
| 25 |
- LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-gateway-master-key}
|
| 26 |
-
#
|
| 27 |
-
#
|
| 28 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
- PORT=4000
|
| 30 |
-
# NOTE: --detailed_debug flag is intentionally omitted.
|
| 31 |
-
# It dumps every internal processing step (including per-token details) to
|
| 32 |
-
# stdout, causing massive log volume and container slowdown in production.
|
| 33 |
-
# Use --debug only during active troubleshooting; omit it normally.
|
| 34 |
command: >
|
| 35 |
--config /app/config.yaml
|
| 36 |
--port 4000
|
|
@@ -60,6 +60,7 @@ services:
|
|
| 60 |
- DB_PATH=/app/data/gateway.db
|
| 61 |
- JWT_SECRET=${JWT_SECRET:-super-secret-jwt-key-change-in-production}
|
| 62 |
- GATEWAY_PUBLIC_URL=${GATEWAY_PUBLIC_URL:-http://localhost}
|
|
|
|
| 63 |
volumes:
|
| 64 |
- backend_data:/app/data
|
| 65 |
depends_on:
|
|
@@ -72,6 +73,7 @@ services:
|
|
| 72 |
interval: 20s
|
| 73 |
timeout: 5s
|
| 74 |
retries: 3
|
|
|
|
| 75 |
|
| 76 |
# ─── Frontend ─────────────────────────────────────────────────────────────
|
| 77 |
frontend:
|
|
@@ -87,6 +89,12 @@ services:
|
|
| 87 |
- gateway_net
|
| 88 |
depends_on:
|
| 89 |
- backend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
# ─── Nginx Reverse Proxy ──────────────────────────────────────────────────
|
| 92 |
nginx:
|
|
@@ -95,15 +103,23 @@ services:
|
|
| 95 |
restart: unless-stopped
|
| 96 |
ports:
|
| 97 |
- "${HTTP_PORT:-80}:80"
|
| 98 |
-
# To enable HTTPS: add certs to nginx/ssl/ and uncomment below
|
| 99 |
# - "${HTTPS_PORT:-443}:443"
|
| 100 |
volumes:
|
| 101 |
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
| 102 |
- nginx_logs:/var/log/nginx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
depends_on:
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
|
|
|
| 107 |
networks:
|
| 108 |
- gateway_net
|
| 109 |
|
|
@@ -114,4 +130,4 @@ volumes:
|
|
| 114 |
|
| 115 |
networks:
|
| 116 |
gateway_net:
|
| 117 |
-
driver: bridge
|
|
|
|
| 8 |
# multiple commits per day; /model/delete field names, config.yaml keys, and
|
| 9 |
# routing behaviour have all changed between minor versions without notice.
|
| 10 |
#
|
| 11 |
+
# Pin to a specific stable version. To upgrade: review release notes at
|
| 12 |
+
# https://docs.litellm.ai/release_notes then bump the version and redeploy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
image: ghcr.io/berriai/litellm:main-v1.81.14-stable
|
| 14 |
container_name: ai_gateway_litellm
|
| 15 |
restart: unless-stopped
|
|
|
|
| 18 |
- litellm_data:/app/data
|
| 19 |
environment:
|
| 20 |
- LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-gateway-master-key}
|
| 21 |
+
# BUG FIX: Added LITELLM_SALT_KEY. If DATABASE_URL is ever configured,
|
| 22 |
+
# LiteLLM uses this key to encrypt provider API keys at rest in the DB.
|
| 23 |
+
# Without it, stored keys are written as plaintext.
|
| 24 |
+
# Set a random value in .env and NEVER change it after first use —
|
| 25 |
+
# changing it makes all previously stored encrypted keys unreadable.
|
| 26 |
+
- LITELLM_SALT_KEY=${LITELLM_SALT_KEY:-}
|
| 27 |
+
# Optional: set DATABASE_URL in .env for model persistence across restarts.
|
| 28 |
+
# Must be a PostgreSQL direct connection URL (port 5432, not pooler port 6432).
|
| 29 |
+
# Example: DATABASE_URL=postgresql://user:pass@host:5432/dbname?sslmode=require
|
| 30 |
+
# Leave blank (default) to run without a database — models are re-registered
|
| 31 |
+
# from SQLite on each backend startup via the /model/new API.
|
| 32 |
+
- DATABASE_URL=${DATABASE_URL:-}
|
| 33 |
- PORT=4000
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
command: >
|
| 35 |
--config /app/config.yaml
|
| 36 |
--port 4000
|
|
|
|
| 60 |
- DB_PATH=/app/data/gateway.db
|
| 61 |
- JWT_SECRET=${JWT_SECRET:-super-secret-jwt-key-change-in-production}
|
| 62 |
- GATEWAY_PUBLIC_URL=${GATEWAY_PUBLIC_URL:-http://localhost}
|
| 63 |
+
- LOG_LEVEL=${LOG_LEVEL:-http}
|
| 64 |
volumes:
|
| 65 |
- backend_data:/app/data
|
| 66 |
depends_on:
|
|
|
|
| 73 |
interval: 20s
|
| 74 |
timeout: 5s
|
| 75 |
retries: 3
|
| 76 |
+
start_period: 10s
|
| 77 |
|
| 78 |
# ─── Frontend ─────────────────────────────────────────────────────────────
|
| 79 |
frontend:
|
|
|
|
| 89 |
- gateway_net
|
| 90 |
depends_on:
|
| 91 |
- backend
|
| 92 |
+
healthcheck:
|
| 93 |
+
test: ["CMD-SHELL", "wget --quiet --tries=1 -O /dev/null http://localhost:80/ || exit 1"]
|
| 94 |
+
interval: 20s
|
| 95 |
+
timeout: 5s
|
| 96 |
+
retries: 3
|
| 97 |
+
start_period: 10s
|
| 98 |
|
| 99 |
# ─── Nginx Reverse Proxy ──────────────────────────────────────────────────
|
| 100 |
nginx:
|
|
|
|
| 103 |
restart: unless-stopped
|
| 104 |
ports:
|
| 105 |
- "${HTTP_PORT:-80}:80"
|
| 106 |
+
# To enable HTTPS: add certs to nginx/ssl/ and uncomment below
|
| 107 |
# - "${HTTPS_PORT:-443}:443"
|
| 108 |
volumes:
|
| 109 |
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
| 110 |
- nginx_logs:/var/log/nginx
|
| 111 |
+
# BUG FIX: Previously used plain depends_on (only waits for container to
|
| 112 |
+
# exist, not for services to be healthy). LiteLLM needs ~60s to initialise;
|
| 113 |
+
# nginx starting too early forwards /v1/ requests to a not-yet-ready
|
| 114 |
+
# upstream and returns 502 to users for the entire startup window.
|
| 115 |
+
# Fix: require both backend and frontend to pass their healthchecks before
|
| 116 |
+
# nginx starts. LiteLLM health is already transitively guaranteed because
|
| 117 |
+
# backend depends_on litellm with condition: service_healthy.
|
| 118 |
depends_on:
|
| 119 |
+
backend:
|
| 120 |
+
condition: service_healthy
|
| 121 |
+
frontend:
|
| 122 |
+
condition: service_healthy
|
| 123 |
networks:
|
| 124 |
- gateway_net
|
| 125 |
|
|
|
|
| 130 |
|
| 131 |
networks:
|
| 132 |
gateway_net:
|
| 133 |
+
driver: bridge
|