Spaces:
Sleeping
Sleeping
File size: 4,658 Bytes
900df0b | 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 | # =============================================================================
# OmniFile AI Processor v3.0 - Docker Compose (Enhanced)
# =============================================================================
# Services: Nginx (LB) + FastAPI Backend + Redis + Celery Worker + Celery Beat + React Frontend
# Updated: 2026-05-03 (Nginx LB + Celery Beat + Resource Limits + Health Checks)
# =============================================================================
version: "3.8"
services:
# === Redis (Message Broker + Cache) ===
redis:
image: redis:7-alpine
container_name: omnifile-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
# === FastAPI Backend ===
backend:
build:
context: .
dockerfile: Dockerfile
container_name: omnifile-backend
ports:
- "5001:5001"
- "7860:7860"
environment:
- REDIS_URL=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TRANSFORMERS_CACHE=/app/models_cache
- TORCH_HOME=/app/models_cache
- LOG_LEVEL=INFO
volumes:
- models_cache:/app/models_cache
- uploads:/app/uploads
- ./data:/app/data
- ./logs:/app/logs
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5001/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
restart: unless-stopped
deploy:
resources:
limits:
cpus: "2"
memory: 8G
reservations:
cpus: "1"
memory: 4G
# === Celery Worker (Async OCR Processing) ===
celery-worker:
build:
context: .
dockerfile: Dockerfile
container_name: omnifile-celery
command: celery -A tasks worker --loglevel=info --concurrency=2 --max-tasks-per-child=50 --without-heartbeat
environment:
- REDIS_URL=redis://redis:6379/0
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TRANSFORMERS_CACHE=/app/models_cache
- TORCH_HOME=/app/models_cache
volumes:
- models_cache:/app/models_cache
- uploads:/app/uploads
- ./data:/app/data
depends_on:
redis:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
cpus: "2"
memory: 6G
reservations:
cpus: "1"
memory: 3G
# === Celery Beat (Scheduled Tasks) ===
celery-beat:
build:
context: .
dockerfile: Dockerfile
container_name: omnifile-celery-beat
command: celery -A tasks beat --loglevel=info --schedule=/app/celerybeat-schedule
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
volumes:
- celery_schedule:/app
depends_on:
redis:
condition: service_healthy
backend:
condition: service_started
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.25"
memory: 256M
# === Nginx (Reverse Proxy + Load Balancer) ===
nginx:
image: nginx:1.25-alpine
container_name: omnifile-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./ssl:/etc/nginx/ssl:ro
- nginx_logs:/var/log/nginx
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80/health"]
interval: 15s
timeout: 5s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
# === React Frontend (Development) ===
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
container_name: omnifile-frontend
ports:
- "3000:3000"
environment:
- VITE_API_URL=http://localhost:5001
volumes:
- ./frontend/src:/app/src
depends_on:
- backend
restart: unless-stopped
volumes:
redis_data:
driver: local
models_cache:
driver: local
uploads:
driver: local
celery_schedule:
driver: local
nginx_logs:
driver: local
|