Three root causes fixed: 1. docker-compose.yml — celery-worker and celery-beat missing PYTHONPATH=/app ForkPoolWorker processes inherit sys.path with '' (CWD), but fork can change CWD so lazy imports like `from db.session import ...` raised ModuleNotFoundError. Adding PYTHONPATH=/app ensures /app is always explicit in the path. 2. provider_config.py — lmstudio SUPPORTS_JSON_MODE set to False LM Studio only accepts response_format type 'json_schema' or 'text', not 'json_object'. GenericOpenAIProvider now omits response_format for lmstudio and relies on parse_classification() fallback (same path as Gemini). 3. generic_openai_provider.py — max_tokens raised 1024→4096 (classify) / 256→1024 (suggest) Qwen3 thinking models (like qwen/qwen3.5-9b) consume reasoning tokens from the same budget. With max_tokens=1024 the model exhausts the budget in the thinking trace, leaving content=''. 4096 gives room for both thinking and the JSON output. Also updates lmstudio PROVIDER_DEFAULTS model to qwen/qwen3.5-9b (confirmed loaded in LM Studio) and context_chars to 32_000 (Qwen3 context window). Tested: classify(invoice_text, ['Finance','Legal','HR']) → topics=['Finance'] ✓ Backend tests: 376 passed ✓ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
205 lines
5.6 KiB
YAML
205 lines
5.6 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
environment:
|
|
POSTGRES_DB: docuvault
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./docker/postgres/initdb.d:/docker-entrypoint-initdb.d:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres -d docuvault"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
minio:
|
|
image: minio/minio:latest
|
|
command: server /data --console-address ":9001"
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
|
# RESEARCH.md Finding 3, T-03-09: allow browser CORS preflight for direct PUT uploads.
|
|
# Use FRONTEND_URL (plain string) not CORS_ORIGINS (pydantic JSON list format).
|
|
MINIO_API_CORS_ALLOW_ORIGIN: ${FRONTEND_URL:-http://localhost:5173}
|
|
MINIO_SERVER_URL: http://localhost:9000
|
|
ports:
|
|
- "9000:9000"
|
|
- "9001:9001"
|
|
volumes:
|
|
- minio_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "mc", "ready", "local"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 15s
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: redis-server --requirepass ${REDIS_PASSWORD}
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
|
|
backend:
|
|
build: ./backend
|
|
ports:
|
|
- "8000:8000"
|
|
volumes:
|
|
- ./backend:/app
|
|
environment:
|
|
- DATABASE_URL=${DATABASE_URL}
|
|
- DATABASE_MIGRATE_URL=${DATABASE_MIGRATE_URL}
|
|
- MINIO_ENDPOINT=${MINIO_ENDPOINT}
|
|
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
|
|
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
|
|
- MINIO_BUCKET=${MINIO_BUCKET}
|
|
- MINIO_PUBLIC_ENDPOINT=${MINIO_PUBLIC_ENDPOINT:-localhost:9000}
|
|
- REDIS_URL=${REDIS_URL}
|
|
- SECRET_KEY=${SECRET_KEY}
|
|
- ADMIN_EMAIL=${ADMIN_EMAIL}
|
|
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
|
|
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:5173}
|
|
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:5173}
|
|
- PYTHONDONTWRITEBYTECODE=1
|
|
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
|
- LOG_JSON=${LOG_JSON:-true}
|
|
- CLOUD_CREDS_KEY=${CLOUD_CREDS_KEY}
|
|
labels:
|
|
logging: "promtail"
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
command: uvicorn main:app --host 0.0.0.0 --port 8000 --workers 2
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
minio:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
read_only: true
|
|
tmpfs:
|
|
- "/tmp:mode=1777"
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- "no-new-privileges:true"
|
|
|
|
celery-worker:
|
|
build: ./backend
|
|
environment:
|
|
- DATABASE_URL=${DATABASE_URL}
|
|
- MINIO_ENDPOINT=${MINIO_ENDPOINT}
|
|
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
|
|
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
|
|
- MINIO_BUCKET=${MINIO_BUCKET}
|
|
- REDIS_URL=${REDIS_URL}
|
|
- CLOUD_CREDS_KEY=${CLOUD_CREDS_KEY}
|
|
- SECRET_KEY=${SECRET_KEY}
|
|
- PYTHONDONTWRITEBYTECODE=1
|
|
- PYTHONPATH=/app
|
|
labels:
|
|
logging: "promtail"
|
|
volumes:
|
|
- ./backend:/app
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
command: celery -A celery_app worker --loglevel=info -Q documents
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
minio:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
read_only: true
|
|
tmpfs:
|
|
- "/tmp:mode=1777"
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- "no-new-privileges:true"
|
|
|
|
celery-beat:
|
|
build: ./backend
|
|
environment:
|
|
- DATABASE_URL=${DATABASE_URL}
|
|
- MINIO_ENDPOINT=${MINIO_ENDPOINT}
|
|
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
|
|
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
|
|
- MINIO_BUCKET=${MINIO_BUCKET}
|
|
- REDIS_URL=${REDIS_URL}
|
|
- PYTHONDONTWRITEBYTECODE=1
|
|
- PYTHONPATH=/app
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
command: celery -A celery_app beat --loglevel=info --schedule /tmp/celerybeat-schedule
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
minio:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
read_only: true
|
|
tmpfs:
|
|
- "/tmp:mode=1777"
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- "no-new-privileges:true"
|
|
|
|
loki:
|
|
image: grafana/loki:latest
|
|
ports:
|
|
- "127.0.0.1:3100:3100"
|
|
volumes:
|
|
- ./docker/loki/loki-config.yaml:/etc/loki/local-config.yaml
|
|
- loki_data:/loki
|
|
command: -config.file=/etc/loki/local-config.yaml
|
|
|
|
promtail:
|
|
image: grafana/promtail:latest
|
|
volumes:
|
|
- ./docker/loki/promtail-config.yaml:/etc/promtail/config.yaml
|
|
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
command: -config.file=/etc/promtail/config.yaml
|
|
depends_on:
|
|
- loki
|
|
|
|
grafana:
|
|
image: grafana/grafana:latest
|
|
ports:
|
|
- "127.0.0.1:3000:3000"
|
|
environment:
|
|
- GF_AUTH_ANONYMOUS_ENABLED=false
|
|
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
|
|
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-changeme}
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
depends_on:
|
|
- loki
|
|
|
|
frontend:
|
|
build: ./frontend
|
|
ports:
|
|
- "5173:5173"
|
|
volumes:
|
|
- ./frontend/src:/app/src
|
|
- ./frontend/index.html:/app/index.html
|
|
depends_on:
|
|
- backend
|
|
command: npm run dev -- --host 0.0.0.0
|
|
|
|
volumes:
|
|
postgres_data:
|
|
minio_data:
|
|
loki_data:
|
|
grafana_data:
|