-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
94 lines (87 loc) · 2.71 KB
/
docker-compose.yml
File metadata and controls
94 lines (87 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
version: "3.8"
services:
ai-service:
build:
context: .
dockerfile: Dockerfile
cache_from:
- python:3.12-slim
container_name: itzip-ai-service
image: itzip-ai:latest
ports:
- "8000:8000"
volumes:
# Mount credentials (read-only)
- ./credentials:/app/credentials:ro
# Mount logs directory for persistence
- ./logs:/app/logs
# Mount law system documents
- ./law_system:/app/law_system
# Mount temp directory for file processing
- ./temp:/app/temp
# Mount data directory for vectorstore and documents
- ./data:/app/data
# Cache pip packages between container recreations
- pip-cache:/root/.cache/pip
env_file:
- .env
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import requests; requests.get('http://localhost:8000/api/health')",
]
interval: 5m # 5분마다 체크
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
memory: 950M # 시스템을 위해 50MB 남겨둠
cpus: "1.0"
reservations:
memory: 800M # 최소 보장 메모리
cpus: "0.5"
# entrypoint 직접 설정
command:
- /bin/bash
- -c
- |
set -e
echo "Starting AI OCR Service..."
# Check Google Cloud credentials
if [ -f '/app/credentials/private_key.json' ]; then
echo "Google Cloud credentials found"
else
echo "Google Cloud credentials not found at /app/credentials/private_key.json"
fi
# Clean up old temporary files
find /app/temp -type f -mtime +1 -delete 2>/dev/null || true
# Initialize vectorstore if needed
if [ -d '/app/data/vectorstore' ] && [ -n "$$(ls -A /app/data/vectorstore 2>/dev/null)" ]; then
echo "Law vectorstore already exists"
else
echo "Checking for law documents..."
if [ -d '/app/data/law_docs' ] && find /app/data/law_docs -name '*.pdf' -print -quit | grep -q .; then
echo "Found law documents, initializing vectorstore..."
python init_vectorstore.py || echo "Vectorstore initialization failed"
else
echo "No law documents found"
mkdir -p /app/data/law_docs
fi
fi
echo "Starting service with $${WORKERS:-1} workers..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers $${WORKERS:-1} --limit-max-requests 100
networks:
- app-network
networks:
app-network:
driver: bridge
name: itzip-network
volumes:
pip-cache:
driver: local