Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
199 lines (170 loc) · 4.53 KB
/
Copy pathdocker-compose.yml
File metadata and controls
199 lines (170 loc) · 4.53 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
services:
# Main OCR API Server
ocr-api:
build: .
image: ocr-processor:2.0.0
container_name: ocr-api
command: api
ports:
- "8000:8000"
environment:
# Application Configuration
- OCR_LOG_LEVEL=INFO
- OCR_DEFAULT_LANGUAGE=heb+eng
- OCR_DEFAULT_MODE=cli
- OCR_MAX_CONCURRENT_JOBS=4
- OCR_MAX_FILE_SIZE=104857600
- OCR_TIMEOUT_PER_FILE=300
# API Configuration
- OCR_ENABLE_API=true
- OCR_API_HOST=0.0.0.0
- OCR_API_PORT=8000
# Database Configuration
- OCR_ENABLE_DATABASE=true
- OCR_DATABASE_URL=postgresql://ocr_user:ocr_password@postgres:5432/ocr_db
# Notification Configuration
- OCR_ENABLE_NOTIFICATIONS=true
- OCR_NOTIFICATION_EMAIL=admin@example.com
- OCR_SMTP_SERVER=smtp.gmail.com
- OCR_SMTP_PORT=587
- OCR_SMTP_USERNAME=${SMTP_USERNAME}
- OCR_SMTP_PASSWORD=${SMTP_PASSWORD}
- OCR_WEBHOOK_URL=${WEBHOOK_URL}
# Logging Configuration
- OCR_LOG_TO_FILE=true
- OCR_LOG_DIRECTORY=/app/logs
- OCR_REMOTE_LOG_URL=${REMOTE_LOG_URL}
volumes:
# Mount data directories
- ./data/input:/app/data/input:ro
- ./data/output:/app/data/output
- ./data/archive:/app/data/archive
- ./logs:/app/logs
- ./temp:/app/temp
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
restart: unless-stopped
# Resource limits
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
reservations:
cpus: '0.5'
memory: 1G
# OCR Processing Worker
ocr-worker:
build: .
image: ocr-processor:2.0.0
container_name: ocr-worker
command: python ocr_combined.py --mode force /app/data/input
environment:
# Same configuration as API
- OCR_LOG_LEVEL=INFO
- OCR_DEFAULT_LANGUAGE=heb+eng
- OCR_DEFAULT_MODE=force
- OCR_MAX_CONCURRENT_JOBS=2
- OCR_MAX_FILE_SIZE=104857600
# Worker specific settings
- OCR_OUTPUT_BASE_DIR=/app/data/output
- OCR_LOG_TO_FILE=true
- OCR_LOG_DIRECTORY=/app/logs
volumes:
# Mount data directories
- ./data/input:/app/data/input:ro
- ./data/output:/app/data/output
- ./data/archive:/app/data/archive
- ./logs:/app/logs
depends_on:
- ocr-api
healthcheck:
test: ["CMD", "pgrep", "-f", "python.*ocr_combined"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
# Resource limits for worker (can be higher for processing)
deploy:
resources:
limits:
cpus: '4.0'
memory: 8G
reservations:
cpus: '1.0'
memory: 2G
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: ocr-postgres
environment:
- POSTGRES_DB=ocr_db
- POSTGRES_USER=ocr_user
- POSTGRES_PASSWORD=ocr_password
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ocr_user -d ocr_db"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# Redis for Caching and Queue Management (Optional)
redis:
image: redis:7-alpine
container_name: ocr-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
# Nginx Reverse Proxy (Optional)
nginx:
image: nginx:alpine
container_name: ocr-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/ssl:/etc/nginx/ssl:ro
- ./logs/nginx:/var/log/nginx
depends_on:
- ocr-api
restart: unless-stopped
# Filebeat for Log Shipping (Optional)
filebeat:
image: docker.elastic.co/beats/filebeat:8.11.0
container_name: ocr-filebeat
volumes:
- ./logs:/var/log/ocr:ro
- ./docker/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
depends_on:
- ocr-api
- ocr-worker
restart: unless-stopped
volumes:
postgres_data:
driver: local
redis_data:
driver: local
networks:
default:
name: ocr-network
driver: bridge