mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
fix(docker): remove spurious backend service from compose split
The backend service at port 4001 was not part of LIT-2815 (UI/gateway split) and duplicated gateway's config without serving a defined role. Remove it so the compose file matches the two-service architecture described in the ticket and PR. Also trim the seven backend-specific test cases and the unused `import os` from test_docker_compose.py; all 17 remaining checks still pass. Resolves LIT-2815
This commit is contained in:
parent
bbb3eaaa07
commit
8fefe3a28d
2 changed files with 2 additions and 74 deletions
|
|
@ -48,30 +48,6 @@ services:
|
|||
retries: 3 # Retry up to 3 times if health check fails
|
||||
start_period: 40s # Wait 40 seconds after container start before beginning health checks
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: backend/Dockerfile
|
||||
image: docker.litellm.ai/berriai/litellm-backend:main-stable
|
||||
ports:
|
||||
- "4001:4001" # Map the container port to the host, change the host port if necessary
|
||||
environment:
|
||||
DATABASE_URL: "postgresql://llmproxy:dbpassword9090@db:5432/litellm"
|
||||
# DATABASE_URL_READ_REPLICA: "postgresql://llmproxy:dbpassword9090@db-reader:5432/litellm"
|
||||
STORE_MODEL_IN_DB: "True" # allows adding models to proxy via UI
|
||||
env_file:
|
||||
- .env # Load local .env file
|
||||
depends_on:
|
||||
- db # Indicates that this service depends on the 'db' service, ensuring 'db' starts first
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:4001/health/liveliness')"
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
db:
|
||||
image: postgres:16
|
||||
restart: always
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Static checks on docker-compose.yml to verify the UI/backend/gateway split.
|
||||
Static checks on docker-compose.yml to verify the UI/gateway split.
|
||||
|
||||
Test matrix
|
||||
-----------
|
||||
|
|
@ -8,32 +8,24 @@ Test matrix
|
|||
|----------------------------------------------------|-------------------------------------------|
|
||||
| `ui` service exists | key present in services dict |
|
||||
| `gateway` service exists | key present in services dict |
|
||||
| `backend` service exists | key present in services dict |
|
||||
| Legacy `litellm` service is gone | key absent from services dict |
|
||||
| `ui` builds from `ui/Dockerfile` | build.dockerfile == "ui/Dockerfile" |
|
||||
| `gateway` builds from `gateway/Dockerfile` | build.dockerfile == "gateway/Dockerfile" |
|
||||
| `backend` builds from `backend/Dockerfile` | build.dockerfile == "backend/Dockerfile" |
|
||||
| `ui` exposes port 3000 | "3000:3000" in ports list |
|
||||
| `gateway` exposes port 4000 | "4000:4000" in ports list |
|
||||
| `backend` exposes port 4001 | "4001:4001" in ports list |
|
||||
| `gateway` has DATABASE_URL env var | key present in environment dict |
|
||||
| `gateway` has STORE_MODEL_IN_DB env var | key present in environment dict |
|
||||
| `backend` has DATABASE_URL env var | key present in environment dict |
|
||||
| `backend` has STORE_MODEL_IN_DB env var | key present in environment dict |
|
||||
| `gateway` health check is configured | healthcheck.test is non-empty |
|
||||
| `backend` health check is configured | healthcheck.test is non-empty |
|
||||
| `ui` health check is configured | healthcheck.test is non-empty |
|
||||
| `gateway` depends on `db` | "db" in depends_on |
|
||||
| `backend` depends on `db` | "db" in depends_on |
|
||||
| `db` service exists | key present in services dict |
|
||||
| `db` health check is configured | healthcheck.test is non-empty |
|
||||
| `prometheus` service exists | key present in services dict |
|
||||
| Named volume `postgres_data` is declared | key present in top-level volumes dict |
|
||||
| `prometheus.yml` scrapes `gateway`, not `litellm` | target contains "gateway:4000" |
|
||||
| `prometheus.yml` does not reference old service | target does not contain "litellm:4000" |
|
||||
| Named volume `postgres_data` is declared | key present in top-level volumes dict |
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
|
@ -68,10 +60,6 @@ def test_gateway_service_exists(services):
|
|||
assert "gateway" in services, "'gateway' service missing from docker-compose.yml"
|
||||
|
||||
|
||||
def test_backend_service_exists(services):
|
||||
assert "backend" in services, "'backend' service missing from docker-compose.yml"
|
||||
|
||||
|
||||
def test_legacy_litellm_service_removed(services):
|
||||
assert "litellm" not in services, (
|
||||
"Monolithic 'litellm' service should be removed after UI/gateway split"
|
||||
|
|
@ -97,13 +85,6 @@ def test_gateway_builds_from_gateway_dockerfile(services):
|
|||
)
|
||||
|
||||
|
||||
def test_backend_builds_from_backend_dockerfile(services):
|
||||
build = services["backend"].get("build", {})
|
||||
assert build.get("dockerfile") == "backend/Dockerfile", (
|
||||
f"backend service should build from backend/Dockerfile, got {build.get('dockerfile')}"
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Port exposure
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -123,13 +104,6 @@ def test_gateway_exposes_port_4000(services):
|
|||
)
|
||||
|
||||
|
||||
def test_backend_exposes_port_4001(services):
|
||||
ports = services["backend"].get("ports", [])
|
||||
assert any("4001" in str(p) for p in ports), (
|
||||
f"backend service should expose port 4001, got ports={ports}"
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Gateway environment variables
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -147,18 +121,6 @@ def test_gateway_has_store_model_in_db(services):
|
|||
)
|
||||
|
||||
|
||||
def test_backend_has_database_url(services):
|
||||
env = services["backend"].get("environment", {})
|
||||
assert "DATABASE_URL" in env, "backend service must have DATABASE_URL environment variable"
|
||||
|
||||
|
||||
def test_backend_has_store_model_in_db(services):
|
||||
env = services["backend"].get("environment", {})
|
||||
assert "STORE_MODEL_IN_DB" in env, (
|
||||
"backend service must have STORE_MODEL_IN_DB environment variable"
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Health checks
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -169,11 +131,6 @@ def test_gateway_healthcheck_configured(services):
|
|||
assert hc.get("test"), "gateway service must have a healthcheck configured"
|
||||
|
||||
|
||||
def test_backend_healthcheck_configured(services):
|
||||
hc = services["backend"].get("healthcheck", {})
|
||||
assert hc.get("test"), "backend service must have a healthcheck configured"
|
||||
|
||||
|
||||
def test_ui_healthcheck_configured(services):
|
||||
hc = services["ui"].get("healthcheck", {})
|
||||
assert hc.get("test"), "ui service must have a healthcheck configured"
|
||||
|
|
@ -189,11 +146,6 @@ def test_gateway_depends_on_db(services):
|
|||
assert "db" in depends_on, "gateway service must depend on the 'db' service"
|
||||
|
||||
|
||||
def test_backend_depends_on_db(services):
|
||||
depends_on = services["backend"].get("depends_on", [])
|
||||
assert "db" in depends_on, "backend service must depend on the 'db' service"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Supporting services
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue