fix: use host networking for voice services to eliminate docker-proxy overhead

Bridge mode created 600+ docker-proxy processes for LiveKit's UDP port-range
mappings (30000-30100, 50000-50200). Switch livekit-server, voice-agent, and
voice-service to network_mode: host for zero-overhead networking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-01 19:58:32 -08:00
parent 186234bae2
commit 68ee2516d5
2 changed files with 13 additions and 21 deletions

View File

@ -312,17 +312,15 @@ services:
- it0-network
# ===== LiveKit Infrastructure =====
# NOTE: livekit-server, voice-agent, voice-service use host networking
# to eliminate docker-proxy overhead for real-time audio (WebRTC UDP).
# Bridge mode created 600+ docker-proxy processes for port-range mappings.
livekit-server:
image: livekit/livekit-server:latest
container_name: it0-livekit-server
restart: unless-stopped
network_mode: host
command: --config /etc/livekit.yaml
ports:
- "17880:7880"
- "17881:7881"
- "3478:3478/udp"
- "30000-30100:30000-30100/udp"
- "50000-50200:50000-50200/udp"
volumes:
- ./livekit.yaml:/etc/livekit.yaml:ro
healthcheck:
@ -330,22 +328,21 @@ services:
interval: 10s
timeout: 5s
retries: 3
networks:
- it0-network
voice-agent:
build:
context: ../../packages/services/voice-agent
container_name: it0-voice-agent
restart: unless-stopped
network_mode: host
volumes:
- ../../data/voice-models/huggingface:/root/.cache/huggingface
- ../../data/voice-models/torch-hub:/root/.cache/torch/hub
environment:
- LIVEKIT_URL=ws://livekit-server:7880
- LIVEKIT_URL=ws://127.0.0.1:7880
- LIVEKIT_API_KEY=devkey
- LIVEKIT_API_SECRET=devsecret
- AGENT_SERVICE_URL=http://agent-service:3002
- AGENT_SERVICE_URL=http://127.0.0.1:13002
- STT_PROVIDER=${STT_PROVIDER:-local}
- TTS_PROVIDER=${TTS_PROVIDER:-local}
- WHISPER_MODEL=${WHISPER_MODEL:-base}
@ -362,24 +359,21 @@ services:
condition: service_healthy
agent-service:
condition: service_healthy
networks:
- it0-network
# ===== Voice Service (legacy WebSocket + Twilio) =====
# ===== Voice Service (LiveKit token + Twilio) =====
voice-service:
build:
context: ../../packages/services/voice-service
container_name: it0-voice-service
restart: unless-stopped
ports:
- "13008:3008"
network_mode: host
volumes:
- ../../data/voice-models/huggingface:/root/.cache/huggingface
- ../../data/voice-models/torch-hub:/root/.cache/torch/hub
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
- ANTHROPIC_BASE_URL=${ANTHROPIC_BASE_URL}
- AGENT_SERVICE_URL=http://agent-service:3002
- AGENT_SERVICE_URL=http://127.0.0.1:13002
- WHISPER_MODEL=${WHISPER_MODEL:-base}
- KOKORO_MODEL=${KOKORO_MODEL:-kokoro-82m}
- KOKORO_VOICE=${KOKORO_VOICE:-zf_xiaoxiao}
@ -393,7 +387,7 @@ services:
- OPENAI_TTS_VOICE=${OPENAI_TTS_VOICE:-coral}
- LIVEKIT_API_KEY=devkey
- LIVEKIT_API_SECRET=devsecret
- LIVEKIT_WS_URL=ws://154.84.135.121:17880
- LIVEKIT_WS_URL=ws://154.84.135.121:7880
healthcheck:
test: ["CMD-SHELL", "python3 -c \"import urllib.request; urllib.request.urlopen('http://localhost:3008/docs')\""]
interval: 30s
@ -402,8 +396,6 @@ services:
start_period: 120s
depends_on:
- agent-service
networks:
- it0-network
# ===== Frontend =====
web-admin:

View File

@ -16,14 +16,14 @@ class AppConfig {
factory AppConfig.development() => const AppConfig(
apiBaseUrl: 'http://10.0.2.2:18000',
wsBaseUrl: 'ws://10.0.2.2:18000',
livekitUrl: 'ws://10.0.2.2:17880',
livekitUrl: 'ws://10.0.2.2:7880',
environment: 'development',
);
factory AppConfig.production() => const AppConfig(
apiBaseUrl: 'http://154.84.135.121:18000',
wsBaseUrl: 'ws://154.84.135.121:18000',
livekitUrl: 'ws://154.84.135.121:17880',
livekitUrl: 'ws://154.84.135.121:7880',
environment: 'production',
);
}