e50869cbda
신규 컨테이너 marker-service (port 3300, Marker 1.10.2 + surya 0.17.1 + HF cache volume). marker_worker 가 markdown stage 큐 소비: classify_worker → enqueue 'markdown' (leaf, embed/chunk 와 독립) → SKIP_DOC_TYPES (발주서/세금계산서/명세표) 스킵 → 확장자 != .pdf 스킵 (Phase 1B = PDF only) → page_count > 200 스킵 → marker-service POST /convert → 422/404 = doc-level failed, 5xx = queue retry 안정성 장치: - migration 222: ALTER TYPE process_stage ADD VALUE markdown (단일 statement) - md_extraction_quality JSONB dict 직접 저장 - skip 시 md_content/hash NULL 클리어 - /ready Response.status_code + warmup_error 가시화 - HF cache volume (build-time download 0) - file_path 는 NAS 상대경로 → /documents prefix prepend 성공 기준: 파이프라인 안정성. markdown 품질은 Phase 1D pilot. Pre-flight (2026-05-01): - marker-pdf 1.10.2 stable - file_path 9503건 NAS 상대경로 - DOCUMENT_TYPES 한국어 7종 → SKIP alias 보강 - queue retry max_attempts=3 + reset_stale_items 확인 - main 220/221 study_q_related 선점 → 222 rebump Plan: ~/.claude/plans/plan-idempotent-sundae.md (Round 5 approved) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
227 lines
6.5 KiB
YAML
227 lines
6.5 KiB
YAML
services:
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
- ./migrations:/docker-entrypoint-initdb.d
|
|
environment:
|
|
POSTGRES_DB: pkm
|
|
POSTGRES_USER: pkm
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
ports:
|
|
- "127.0.0.1:15432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U pkm"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
kordoc-service:
|
|
build: ./services/kordoc
|
|
ports:
|
|
- "127.0.0.1:3100:3100"
|
|
volumes:
|
|
- ${NAS_NFS_PATH:-/mnt/nas/Document_Server}:/documents:ro
|
|
mem_limit: 4g
|
|
memswap_limit: 4g
|
|
healthcheck:
|
|
test: ["CMD", "node", "-e", "fetch('http://localhost:3100/health').then(r=>{process.exit(r.ok?0:1)}).catch(()=>process.exit(1))"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
restart: unless-stopped
|
|
|
|
ocr-service:
|
|
build: ./services/ocr
|
|
expose:
|
|
- "3200"
|
|
volumes:
|
|
- ${NAS_NFS_PATH:-/mnt/nas/Document_Server}:/documents:ro
|
|
- ocr_models:/root/.cache
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: 1
|
|
capabilities: [gpu]
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:3200/health')"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 180s
|
|
restart: unless-stopped
|
|
|
|
# Phase 1B (2026-05-01): PDF → markdown 변환. ocr-service 와 별도 컨테이너 (deps 충돌 회피).
|
|
marker-service:
|
|
build: ./services/marker
|
|
ports:
|
|
- "127.0.0.1:3300:3300"
|
|
expose:
|
|
- "3300"
|
|
environment:
|
|
- HF_HOME=/models/huggingface
|
|
- TORCH_HOME=/models/torch
|
|
volumes:
|
|
- ${NAS_NFS_PATH:-/mnt/nas/Document_Server}:/documents:ro
|
|
- marker_models:/models
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: 1
|
|
capabilities: [gpu]
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3300/ready"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 300s
|
|
restart: unless-stopped
|
|
|
|
stt-service:
|
|
# 2026-04-24: STT 가 Mac mini (faster-whisper, 192.168.1.122:8804 / 100.76.254.116:8804)
|
|
# 로 이전됨. GPU 에서 컨테이너는 더 이상 기동하지 않는다. 복원이 필요하면
|
|
# `docker compose --profile legacy up -d stt-service` 로 legacy 프로파일 활성화.
|
|
# fastapi 의 STT_ENDPOINT 도 Mac mini 주소를 가리킴 (아래 environment 참고).
|
|
profiles: [legacy]
|
|
build: ./services/stt
|
|
expose:
|
|
- "3300"
|
|
volumes:
|
|
- ${NAS_NFS_PATH:-/mnt/nas/Document_Server}:/documents:ro
|
|
- stt_models:/root/.cache
|
|
environment:
|
|
- WHISPER_MODEL=${WHISPER_MODEL:-large-v3}
|
|
- WHISPER_DEVICE=${WHISPER_DEVICE:-cuda}
|
|
- WHISPER_COMPUTE_TYPE=${WHISPER_COMPUTE_TYPE:-float16}
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: 1
|
|
capabilities: [gpu]
|
|
healthcheck:
|
|
# /ready: CUDA 디바이스 + 모델 적재 둘 다 확인. ready=true 만 healthy 처리.
|
|
# /health 는 단순 liveness 라 모델 미적재 상태도 healthy 로 잡혀 운영 신호로 부적합.
|
|
test: ["CMD", "python3", "-c", "import json,urllib.request,sys; r=urllib.request.urlopen('http://localhost:3300/ready'); sys.exit(0 if json.load(r).get('ready') else 1)"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 300s
|
|
restart: unless-stopped
|
|
|
|
ollama:
|
|
image: ollama/ollama
|
|
volumes:
|
|
- ollama_data:/root/.ollama
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: 1
|
|
capabilities: [gpu]
|
|
ports:
|
|
- "127.0.0.1:11434:11434"
|
|
restart: unless-stopped
|
|
|
|
# Phase 1.3: bge-reranker-v2-m3 (TEI) — internal only, fastapi에서 reranker:80으로 호출
|
|
# fastapi가 depends_on 안 함 → 단독 시작 가능, 없어도 fastapi 동작 (rerank=false fallback)
|
|
reranker:
|
|
image: ghcr.io/huggingface/text-embeddings-inference:1.7
|
|
container_name: hyungi_document_server-reranker-1
|
|
expose:
|
|
- "80"
|
|
environment:
|
|
- MODEL_ID=BAAI/bge-reranker-v2-m3
|
|
- MAX_BATCH_TOKENS=8192
|
|
- MAX_CONCURRENT_REQUESTS=4
|
|
volumes:
|
|
- reranker_cache:/data
|
|
deploy:
|
|
resources:
|
|
reservations:
|
|
devices:
|
|
- driver: nvidia
|
|
count: 1
|
|
capabilities: [gpu]
|
|
restart: unless-stopped
|
|
|
|
ai-gateway:
|
|
build: ./gpu-server/services/ai-gateway
|
|
ports:
|
|
- "127.0.0.1:8081:8080"
|
|
environment:
|
|
- PRIMARY_ENDPOINT=http://100.76.254.116:8801/v1/chat/completions
|
|
- FALLBACK_ENDPOINT=http://ollama:11434/v1/chat/completions
|
|
- CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
|
|
- DAILY_BUDGET_USD=${DAILY_BUDGET_USD:-5.00}
|
|
depends_on:
|
|
- ollama
|
|
restart: unless-stopped
|
|
|
|
fastapi:
|
|
build: ./app
|
|
ports:
|
|
- "127.0.0.1:8000:8000"
|
|
volumes:
|
|
- ${NAS_NFS_PATH:-/mnt/nas/Document_Server}:/documents
|
|
- ./config.yaml:/app/config.yaml:ro
|
|
- ./domain_policy.yaml:/app/domain_policy.yaml:ro
|
|
- ./scripts:/app/scripts:ro
|
|
- ./logs:/app/logs
|
|
- ./migrations:/app/migrations:ro
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
kordoc-service:
|
|
condition: service_healthy
|
|
marker-service:
|
|
condition: service_healthy
|
|
env_file:
|
|
- credentials.env
|
|
environment:
|
|
- DATABASE_URL=postgresql+asyncpg://pkm:${POSTGRES_PASSWORD}@postgres:5432/pkm
|
|
- KORDOC_ENDPOINT=http://kordoc-service:3100
|
|
- OCR_ENDPOINT=http://ocr-service:3200
|
|
- MARKER_ENDPOINT=http://marker-service:3300
|
|
- MARKER_CONTAINER_PATH_PREFIX=/documents
|
|
# 2026-04-24 STT Mac mini 이전: 기본값 100.76.254.116:8804 (Tailscale), 필요 시
|
|
# MAC_MINI_HOST env 로 192.168.1.122 등 LAN IP 주입.
|
|
- STT_ENDPOINT=http://${MAC_MINI_HOST:-100.76.254.116}:8804
|
|
restart: unless-stopped
|
|
|
|
frontend:
|
|
build: ./frontend
|
|
ports:
|
|
- "127.0.0.1:3000:3000"
|
|
depends_on:
|
|
- fastapi
|
|
restart: unless-stopped
|
|
|
|
caddy:
|
|
image: caddy:2
|
|
ports:
|
|
- "8080:80"
|
|
volumes:
|
|
- ./Caddyfile:/etc/caddy/Caddyfile
|
|
- caddy_data:/data
|
|
depends_on:
|
|
- fastapi
|
|
- frontend
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|
|
caddy_data:
|
|
ollama_data:
|
|
reranker_cache:
|
|
ocr_models:
|
|
stt_models:
|
|
marker_models:
|