/
AlexandrNarbaev
/
rag-system
Обзор
Документация
Войти
/
AlexandrNarbaev
/
rag-system
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
deploy/docker/docker-compose.distributed.yml
386 строк
13 KB
Alexandr Narbaev
RAG System Init
19 июл 2026, 13:55
19 июл 2026, 13:55
59d6dd0
Код
Авторство
О чём код?
# docker-compose.distributed.yml # Multi-machine distributed deployment for RAG System. # # ── Machine 1 (Proxy + Qdrant + Neo4j + Redis + MinIO) ── # docker compose -f docker-compose.distributed.yml up -d proxy qdrant neo4j redis minio # # ── Machine 2 (OpenWebUI) ── # docker compose -f docker-compose.distributed.yml up -d openwebui postgres tika # # ── Machine 3 (ETL Worker) ── # docker compose -f docker-compose.distributed.yml up -d etl # # Prerequisites: # - Shared network `rag-network` (Docker Swarm overlay or manually bridged) # - Shared volumes for Qdrant, Neo4j, Redis data (NFS or distributed FS) # - All machines must be in the same Docker Swarm or have routable IPs # # Environment: copy .env.example to .env and configure # QDRANT_HOST, NEO4J_URI, REDIS_URL must point to Machine 1 services: # ═══════════════════════════════════════════════════════════════════════════════ # Machine 1 — Core Infrastructure # ═══════════════════════════════════════════════════════════════════════════════ # ── Qdrant (vector database) ────────────────────────────────────────────────── qdrant: image: qdrant/qdrant:v1.12.1 container_name: rag-qdrant volumes: - qdrant_data:/qdrant/storage ports: - "6333:6333" - "6334:6334" environment: - QDRANT__SERVICE__GRPC_PORT=6334 deploy: resources: limits: cpus: "4" memory: 8G reservations: cpus: "1" memory: 2G healthcheck: test: ["CMD", "curl", "-f", "http://localhost:6333/healthz"] interval: 10s timeout: 5s retries: 3 start_period: 15s restart: unless-stopped networks: - rag-network # ── Neo4j (graph database) ──────────────────────────────────────────────────── neo4j: image: neo4j:5-community container_name: rag-neo4j volumes: - neo4j_data:/data - neo4j_logs:/logs ports: - "7474:7474" - "7687:7687" environment: - NEO4J_AUTH=${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-password} - NEO4J_server_memory_pagecache_size=1G - NEO4J_server_memory_heap_initial__size=1G - NEO4J_server_memory_heap_max__size=2G deploy: resources: limits: cpus: "4" memory: 4G reservations: cpus: "0.5" memory: 2G healthcheck: test: ["CMD", "neo4j", "status"] interval: 15s timeout: 5s retries: 5 start_period: 60s restart: unless-stopped networks: - rag-network # ── Redis (shared cache) ────────────────────────────────────────────────────── redis: image: redis:7-alpine container_name: rag-redis ports: - "6379:6379" volumes: - redis_data:/data command: redis-server --appendonly yes --maxmemory 2gb --maxmemory-policy allkeys-lru --save 900 1 300 10 deploy: resources: limits: cpus: "1" memory: 2G reservations: cpus: "0.1" memory: 256M healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 3 start_period: 5s restart: unless-stopped networks: - rag-network # ── MinIO (object storage) ──────────────────────────────────────────────────── minio: image: minio/minio:RELEASE.2024-11-07T00-52-20Z container_name: rag-minio volumes: - minio_data:/data ports: - "9000:9000" - "9001:9001" environment: - MINIO_ROOT_USER=${MINIO_ROOT_USER:-CHANGE_ME} - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-CHANGE_ME} command: server /data --console-address ":9001" deploy: resources: limits: cpus: "2" memory: 4G reservations: cpus: "0.5" memory: 1G healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] interval: 15s timeout: 5s retries: 3 start_period: 30s restart: unless-stopped networks: - rag-network # ── RAG Proxy (FastAPI) ─────────────────────────────────────────────────────── proxy: build: context: ../.. dockerfile: proxy/Dockerfile container_name: rag-proxy ports: - "8080:8080" volumes: - ${MODEL_CACHE_PATH:-/opt/models/cache}:/app/cache:ro - ../../proxy/.env:/app/.env:ro - proxy_logs:/app/logs environment: - QDRANT_HOST=${QDRANT_HOST:-qdrant} - QDRANT_PORT=${QDRANT_PORT:-6333} - QDRANT_GRPC_ENABLED=${QDRANT_GRPC_ENABLED:-true} - QDRANT_GRPC_PORT=${QDRANT_GRPC_PORT:-6334} - QDRANT_QUANTIZATION_ENABLED=${QDRANT_QUANTIZATION_ENABLED:-true} - NEO4J_URI=${NEO4J_URI:-bolt://neo4j:7687} - REDIS_URL=${REDIS_URL:-redis://redis:6379/0} - LLM_ENDPOINT=${LLM_ENDPOINT:-http://vllm:8000/v1} - MINIO_ENDPOINT=${MINIO_ENDPOINT:-minio:9000} - USE_REDIS=true - USE_LANGGRAPH=true - GRAPH_ENABLED=true - METRICS_ENABLED=true - LOG_FORMAT=json - PREFIX_CACHING_ENABLED=true depends_on: qdrant: condition: service_healthy neo4j: condition: service_healthy redis: condition: service_healthy deploy: resources: limits: cpus: "4" memory: 8G reservations: cpus: "1" memory: 2G healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/v1/health/live"] interval: 10s timeout: 5s retries: 3 start_period: 60s restart: unless-stopped stop_grace_period: 45s networks: - rag-network # ═══════════════════════════════════════════════════════════════════════════════ # Machine 2 — OpenWebUI Interface # ═══════════════════════════════════════════════════════════════════════════════ openwebui: image: ghcr.io/open-webui/open-webui:main container_name: rag-openwebui ports: - "3000:8080" environment: - WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY} - DATABASE_URL=postgresql://${OWUI_DB_USER:-openwebui}:${OWUI_DB_PASSWORD}@postgres:5432/${OWUI_DB_NAME:-openwebui} - REDIS_URL=redis://rag-redis:6379/1 - OPENAI_API_BASE_URLS=${OPENAI_API_BASE_URLS:-http://rag-proxy:8080/v1} - OPENAI_API_KEYS=${OPENAI_API_KEYS:-sk-rag-proxy} - STORAGE_PROVIDER=${STORAGE_PROVIDER:-s3} - S3_ENDPOINT_URL=${S3_ENDPOINT_URL:-http://rag-minio:9000} - S3_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} - S3_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} - S3_BUCKET_NAME=${S3_BUCKET_NAME:-openwebui-files} - S3_REGION_NAME=${S3_REGION_NAME:-us-east-1} - S3_ADDRESSING_STYLE=${S3_ADDRESSING_STYLE:-path} - CONTENT_EXTRACTION_ENGINE=${CONTENT_EXTRACTION_ENGINE:-tika} - TIKA_SERVER_URL=${TIKA_SERVER_URL:-http://tika:9998} volumes: - openwebui_data:/app/backend/data - openwebui_tmp:/tmp depends_on: postgres: condition: service_healthy tika: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 15s timeout: 10s retries: 5 start_period: 45s restart: unless-stopped stop_grace_period: 30s deploy: resources: limits: cpus: "2" memory: 2G reservations: cpus: "0.5" memory: 512M networks: - rag-network # ── PostgreSQL (OpenWebUI metadata) ─────────────────────────────────────────── postgres: image: postgres:16-alpine container_name: rag-openwebui-postgres ports: - "127.0.0.1:5432:5432" environment: - POSTGRES_USER=${OWUI_DB_USER:-openwebui} - POSTGRES_PASSWORD=${OWUI_DB_PASSWORD} - POSTGRES_DB=${OWUI_DB_NAME:-openwebui} - PGDATA=/var/lib/postgresql/data/pgdata volumes: - postgres_data:/var/lib/postgresql/data command: > postgres -c shared_buffers=256MB -c effective_cache_size=768MB -c maintenance_work_mem=64MB -c max_connections=50 -c random_page_cost=1.1 healthcheck: test: ["CMD-SHELL", "pg_isready -U ${OWUI_DB_USER:-openwebui} -d ${OWUI_DB_NAME:-openwebui}"] interval: 10s timeout: 5s retries: 5 start_period: 20s restart: unless-stopped stop_grace_period: 60s deploy: resources: limits: cpus: "2" memory: 1G reservations: cpus: "0.25" memory: 256M networks: - rag-network # ── Apache Tika (document extraction) ───────────────────────────────────────── tika: image: apache/tika:latest container_name: rag-openwebui-tika environment: - TIKA_CHILD_JAVA_OPTS=-Xmx512m - JAVA_TOOL_OPTIONS=-Xmx512m tmpfs: - /tmp:size=512M,mode=1777 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:9998/tika"] interval: 30s timeout: 15s retries: 3 start_period: 45s restart: unless-stopped deploy: resources: limits: cpus: "2" memory: 1G reservations: cpus: "0.25" memory: 256M networks: - rag-network # ═══════════════════════════════════════════════════════════════════════════════ # Machine 3 — ETL Worker # ═══════════════════════════════════════════════════════════════════════════════ etl: build: context: ../.. dockerfile: etl/Dockerfile.etl container_name: rag-etl volumes: - ../../etl/config:/app/etl/config:ro - etl_data:/app/etl/data environment: - QDRANT_HOST=${QDRANT_HOST:-rag-qdrant} - QDRANT_PORT=${QDRANT_PORT:-6333} - NEO4J_URI=${NEO4J_URI:-bolt://rag-neo4j:7687} - NEO4J_USER=${NEO4J_USER:-neo4j} - NEO4J_PASSWORD=${NEO4J_PASSWORD} - ETL_SECRET=${ETL_SECRET} - CONFLUENCE_API_URL=${CONFLUENCE_API_URL} - CONFLUENCE_API_TOKEN=${CONFLUENCE_API_TOKEN} - JIRA_API_URL=${JIRA_API_URL} - JIRA_API_TOKEN=${JIRA_API_TOKEN} - GITLAB_API_URL=${GITLAB_API_URL} - GITLAB_API_TOKEN=${GITLAB_API_TOKEN} command: python scheduler/run_etl.py --config /app/etl/config/etl_config.yaml deploy: resources: limits: cpus: "4" memory: 8G reservations: cpus: "1" memory: 2G restart: unless-stopped networks: - rag-network # ═════════════════════════════════════════════════════════════════════════════════ # Volumes # ═════════════════════════════════════════════════════════════════════════════════ volumes: qdrant_data: driver: local neo4j_data: driver: local neo4j_logs: driver: local redis_data: driver: local minio_data: driver: local proxy_logs: driver: local postgres_data: driver: local openwebui_data: driver: local openwebui_tmp: driver: local etl_data: driver: local # ═════════════════════════════════════════════════════════════════════════════════ # Network # ═════════════════════════════════════════════════════════════════════════════════ networks: rag-network: name: rag-network external: true