Skip to content

Commit e565ea7

Browse files
ShaerWareclaude
andauthored
feat(docker): Use local vLLM by default, streamline Docker setup (#54)
- docker-compose.yml now uses local vLLM (host.docker.internal:11434) instead of containerized vLLM - faster startup, no 9GB image download - Add docker-compose.full.yml for full containerized deployment - Update Dockerfile to use nvidia/cuda base + pip install PyTorch (more reliable than pulling pytorch/pytorch image) - Simplify docker-compose.cpu.yml - Update google-generativeai>=0.5.0 (fix system_instruction error) - Streamline CLAUDE.md (~40% reduction, focus on practical dev tasks) - Update README.md with new Docker options Docker usage: - Local vLLM: ./start_qwen.sh && docker compose up -d - Full containerized: docker compose -f ... -f docker-compose.full.yml up -d - CPU mode: docker compose -f ... -f docker-compose.cpu.yml up -d Co-authored-by: ShaerWare <shaerware@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 89041d4 commit e565ea7

7 files changed

Lines changed: 264 additions & 407 deletions

File tree

CLAUDE.md

Lines changed: 127 additions & 300 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ COPY admin/ ./
1919
RUN npm run build
2020

2121
# -----------------------------------------------------------------------------
22-
# Stage 2: Python Runtime with CUDA support
22+
# Stage 2: Python Runtime with CUDA
2323
# -----------------------------------------------------------------------------
24+
# Using nvidia/cuda base (smaller, likely cached) + install PyTorch via pip
2425
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04 AS runtime
2526

26-
# Prevent interactive prompts during package installation
2727
ENV DEBIAN_FRONTEND=noninteractive
2828

29-
# System dependencies
29+
# System dependencies + Python
3030
RUN apt-get update && apt-get install -y --no-install-recommends \
3131
python3.11 \
3232
python3.11-venv \
@@ -42,25 +42,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4242

4343
WORKDIR /app
4444

45-
# Create virtual environment
45+
# Create venv
4646
RUN python -m venv /opt/venv
4747
ENV PATH="/opt/venv/bin:$PATH"
4848

49-
# Upgrade pip
50-
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
49+
# Install PyTorch + torchaudio (with pip cache for resume on network issues)
50+
RUN --mount=type=cache,target=/root/.cache/pip \
51+
pip install --upgrade pip setuptools wheel \
52+
&& pip install torch==2.3.1 torchaudio==2.3.1 \
53+
--index-url https://download.pytorch.org/whl/cu121
5154

52-
# Install PyTorch with CUDA support first (large dependency)
53-
RUN pip install --no-cache-dir \
54-
torch==2.1.2 \
55-
torchaudio==2.1.2 \
56-
--index-url https://download.pytorch.org/whl/cu121
57-
58-
# Install remaining Python dependencies
55+
# Install remaining dependencies
5956
COPY requirements.txt .
60-
RUN pip install --no-cache-dir -r requirements.txt
57+
RUN --mount=type=cache,target=/root/.cache/pip \
58+
pip install -r requirements.txt
6159

6260
# Application code
6361
COPY *.py ./
62+
COPY app/ ./app/
6463
COPY db/ ./db/
6564
COPY alembic/ ./alembic/
6665
COPY alembic.ini ./
@@ -119,14 +118,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
119118

120119
WORKDIR /app
121120

122-
# Install Python dependencies (CPU versions)
121+
# Install Python dependencies (CPU versions, uses cache mount)
123122
COPY requirements.txt .
124-
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
125-
&& pip install --no-cache-dir torch torchaudio --index-url https://download.pytorch.org/whl/cpu \
126-
&& pip install --no-cache-dir -r requirements.txt
123+
RUN --mount=type=cache,target=/root/.cache/pip \
124+
pip install --upgrade pip setuptools wheel \
125+
&& pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu \
126+
&& pip install -r requirements.txt
127127

128128
# Application code
129129
COPY *.py ./
130+
COPY app/ ./app/
130131
COPY db/ ./db/
131132
COPY alembic/ ./alembic/
132133
COPY alembic.ini ./

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ cd AI_Secretary_System
8787
cp .env.docker .env
8888
# Edit .env: set GEMINI_API_KEY for cloud fallback
8989

90-
# GPU Mode (XTTS + vLLM) - requires NVIDIA GPU 12GB+
91-
docker compose up -d
90+
# Option 1: Use LOCAL vLLM (recommended - faster, no 9GB download)
91+
./start_qwen.sh # Start local vLLM first
92+
docker compose up -d # Start orchestrator + redis
9293

93-
# CPU Mode (Piper + Gemini) - no GPU required
94+
# Option 2: FULL containerized (downloads ~9GB vLLM image)
95+
docker compose -f docker-compose.yml -f docker-compose.full.yml up -d
96+
97+
# Option 3: CPU Mode (Piper + Gemini) - no GPU required
9498
docker compose -f docker-compose.yml -f docker-compose.cpu.yml up -d
9599

96100
# Check status

docker-compose.cpu.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# =============================================================================
2-
# AI Secretary System - Docker Compose Override (CPU Mode)
2+
# AI Secretary System - CPU Mode (no GPU required)
33
# =============================================================================
44
#
5+
# Uses Piper TTS (CPU) + Gemini API instead of XTTS + vLLM.
6+
#
57
# Usage:
68
# docker compose -f docker-compose.yml -f docker-compose.cpu.yml up -d
79
#
8-
# This override file:
9-
# - Uses CPU-only image (smaller, no CUDA)
10-
# - Disables vLLM service
11-
# - Sets Gemini as default LLM backend
12-
# - Uses Piper TTS instead of XTTS
13-
#
1410
# =============================================================================
1511

1612
services:
@@ -19,25 +15,13 @@ services:
1915
target: cpu
2016
image: ai-secretary:cpu
2117
environment:
22-
# Override to use cloud LLM
18+
# Use cloud LLM instead of local vLLM
2319
- LLM_BACKEND=gemini
2420
- VLLM_API_URL=
21+
- GEMINI_API_KEY=${GEMINI_API_KEY:?GEMINI_API_KEY required for CPU mode}
2522
# Disable CUDA
2623
- CUDA_VISIBLE_DEVICES=
27-
depends_on:
28-
redis:
29-
condition: service_healthy
30-
# Remove vLLM dependency
3124
deploy:
3225
resources:
3326
reservations:
34-
devices: []
35-
36-
# Disable vLLM service in CPU mode
37-
vllm:
38-
profiles:
39-
- gpu-only
40-
41-
# Redis still used for caching
42-
redis:
43-
# No changes needed
27+
devices: [] # No GPU

docker-compose.full.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# =============================================================================
2+
# AI Secretary System - Full Containerized Setup (with vLLM container)
3+
# =============================================================================
4+
#
5+
# Use this for production deployment or CI/CD where you need everything in Docker.
6+
# WARNING: vLLM image is ~9GB, first pull takes time.
7+
#
8+
# Usage:
9+
# docker compose -f docker-compose.yml -f docker-compose.full.yml up -d
10+
#
11+
# =============================================================================
12+
13+
services:
14+
orchestrator:
15+
environment:
16+
# Override to use containerized vLLM
17+
- VLLM_API_URL=http://vllm:8000/v1
18+
extra_hosts: [] # Remove host.docker.internal
19+
depends_on:
20+
redis:
21+
condition: service_healthy
22+
vllm:
23+
condition: service_healthy
24+
volumes:
25+
# Persistent data
26+
- ./data:/app/data
27+
- ./logs:/app/logs
28+
- ./models:/app/models
29+
# Voice samples
30+
- ./Гуля:/app/Гуля:ro
31+
- ./Лидия:/app/Лидия:ro
32+
# Named volumes for caches (not host mounts)
33+
- tts_cache:/root/.local/share/tts
34+
- hf_cache:/root/.cache/huggingface
35+
36+
# ---------------------------------------------------------------------------
37+
# vLLM - Local LLM Inference Server (containerized)
38+
# ---------------------------------------------------------------------------
39+
vllm:
40+
image: vllm/vllm-openai:latest
41+
container_name: ai-secretary-vllm
42+
command: >
43+
--model ${VLLM_MODEL:-Qwen/Qwen2.5-7B-Instruct-AWQ}
44+
--gpu-memory-utilization 0.5
45+
--max-model-len 4096
46+
--dtype float16
47+
--max-num-seqs 32
48+
--enforce-eager
49+
--trust-remote-code
50+
--host 0.0.0.0
51+
--port 8000
52+
volumes:
53+
- hf_cache:/root/.cache/huggingface
54+
- ./finetune/adapters:/app/adapters:ro
55+
environment:
56+
- HUGGING_FACE_HUB_TOKEN=${HF_TOKEN:-}
57+
- VLLM_LOGGING_LEVEL=WARNING
58+
deploy:
59+
resources:
60+
reservations:
61+
devices:
62+
- driver: nvidia
63+
count: 1
64+
capabilities: [gpu]
65+
healthcheck:
66+
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
67+
interval: 30s
68+
timeout: 10s
69+
retries: 20
70+
start_period: 180s
71+
restart: unless-stopped
72+
networks:
73+
- ai-secretary
74+
75+
volumes:
76+
tts_cache:
77+
driver: local
78+
hf_cache:
79+
driver: local

docker-compose.yml

Lines changed: 18 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# =============================================================================
2-
# AI Secretary System - Docker Compose (GPU Mode)
2+
# AI Secretary System - Docker Compose
33
# =============================================================================
44
#
5+
# Default: Uses LOCAL vLLM (start with ./start_qwen.sh before docker compose)
6+
#
57
# Usage:
6-
# docker compose up -d # Start all services
7-
# docker compose logs -f orchestrator # View logs
8-
# docker compose down # Stop all services
8+
# ./start_qwen.sh # Start local vLLM first
9+
# docker compose up -d # Start orchestrator + redis
10+
# docker compose logs -f orchestrator
911
#
10-
# Requirements:
11-
# - NVIDIA GPU with 12GB+ VRAM
12-
# - NVIDIA Container Toolkit installed
13-
# - Docker Compose v2.x
12+
# For FULL containerized setup (downloads ~9GB vLLM image):
13+
# docker compose -f docker-compose.yml -f docker-compose.full.yml up -d
1414
#
1515
# =============================================================================
1616

@@ -32,19 +32,19 @@ services:
3232
- ./data:/app/data
3333
- ./logs:/app/logs
3434
- ./models:/app/models
35-
# Voice samples (read-only, already in image but can override)
35+
# Voice samples
3636
- ./Гуля:/app/Гуля:ro
3737
- ./Лидия:/app/Лидия:ro
38-
# Model caches (named volumes for persistence)
39-
- tts_cache:/root/.cache/tts_models
40-
- hf_cache:/root/.cache/huggingface
38+
# Mount LOCAL caches (no re-download)
39+
- ${HOME}/.cache/huggingface:/root/.cache/huggingface
40+
- ${HOME}/.local/share/tts:/root/.local/share/tts
4141
environment:
42-
# LLM Configuration
42+
# LLM - connect to LOCAL vLLM on host
4343
- LLM_BACKEND=${LLM_BACKEND:-vllm}
44-
- VLLM_API_URL=http://vllm:8000/v1
44+
- VLLM_API_URL=http://host.docker.internal:11434/v1
4545
- VLLM_MODEL_NAME=${VLLM_MODEL_NAME:-}
4646
- SECRETARY_PERSONA=${SECRETARY_PERSONA:-gulya}
47-
# Cloud LLM (optional fallback)
47+
# Cloud LLM fallback
4848
- GEMINI_API_KEY=${GEMINI_API_KEY:-}
4949
# Database
5050
- REDIS_URL=redis://redis:6379/0
@@ -53,12 +53,12 @@ services:
5353
- ADMIN_JWT_SECRET=${ADMIN_JWT_SECRET:-}
5454
# TTS
5555
- COQUI_TOS_AGREED=1
56-
- TTS_CACHE_PATH=/root/.cache/tts_models
56+
- TTS_CACHE_PATH=/root/.local/share/tts
57+
extra_hosts:
58+
- "host.docker.internal:host-gateway"
5759
depends_on:
5860
redis:
5961
condition: service_healthy
60-
vllm:
61-
condition: service_healthy
6262
deploy:
6363
resources:
6464
reservations:
@@ -76,45 +76,6 @@ services:
7676
retries: 3
7777
start_period: 60s
7878

79-
# ---------------------------------------------------------------------------
80-
# vLLM - Local LLM Inference Server
81-
# ---------------------------------------------------------------------------
82-
vllm:
83-
image: vllm/vllm-openai:latest
84-
container_name: ai-secretary-vllm
85-
command: >
86-
--model ${VLLM_MODEL:-Qwen/Qwen2.5-7B-Instruct-AWQ}
87-
--gpu-memory-utilization 0.5
88-
--max-model-len 4096
89-
--dtype float16
90-
--max-num-seqs 32
91-
--enforce-eager
92-
--trust-remote-code
93-
--host 0.0.0.0
94-
--port 8000
95-
volumes:
96-
- hf_cache:/root/.cache/huggingface
97-
- ./finetune/adapters:/app/adapters:ro
98-
environment:
99-
- HUGGING_FACE_HUB_TOKEN=${HF_TOKEN:-}
100-
- VLLM_LOGGING_LEVEL=WARNING
101-
deploy:
102-
resources:
103-
reservations:
104-
devices:
105-
- driver: nvidia
106-
count: 1
107-
capabilities: [gpu]
108-
healthcheck:
109-
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
110-
interval: 30s
111-
timeout: 10s
112-
retries: 20
113-
start_period: 180s
114-
restart: unless-stopped
115-
networks:
116-
- ai-secretary
117-
11879
# ---------------------------------------------------------------------------
11980
# Redis - Caching and Rate Limiting
12081
# ---------------------------------------------------------------------------
@@ -139,10 +100,6 @@ services:
139100
volumes:
140101
redis_data:
141102
driver: local
142-
tts_cache:
143-
driver: local
144-
hf_cache:
145-
driver: local
146103

147104
# =============================================================================
148105
# Networks

requirements.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ pydub==0.25.1
2323
python-telegram-bot==21.0.1
2424

2525
# AI Integration
26-
google-generativeai==0.3.2
26+
google-generativeai>=0.5.0
2727
requests==2.31.0
2828
aiohttp==3.9.1
2929

3030
# Utils
3131
python-dotenv==1.0.0
3232
pydantic==2.5.3
3333
numpy==1.24.3
34-
torch==2.1.2
35-
torchaudio==2.1.2
34+
35+
# PyTorch (installed separately in Dockerfile for CUDA support)
36+
# torch==2.3.1
37+
# torchaudio==2.3.1
38+
39+
# Pin transformers for TTS compatibility
40+
transformers>=4.41.0,<5.0.0
3641

3742
# System monitoring
3843
psutil==5.9.8

0 commit comments

Comments
 (0)