Hoghoghi / docker-compose.yaml
Really-amin's picture
Upload 2 files
546331e verified
version: '3.8'
services:
# Persian Legal Scraper Main Application
persian-legal-scraper:
build:
context: .
dockerfile: Dockerfile
container_name: persian-legal-scraper-app
restart: unless-stopped
ports:
- "7860:7860"
environment:
# Application Settings
- PYTHONPATH=/app
- PYTHONUNBUFFERED=1
- LOG_LEVEL=INFO
- ENVIRONMENT=production
# Gradio Configuration
- GRADIO_SERVER_NAME=0.0.0.0
- GRADIO_SERVER_PORT=7860
- GRADIO_SHARE=false
- GRADIO_THEME=default
# AI/ML Model Settings
- HF_HOME=/app/cache
- TRANSFORMERS_CACHE=/app/cache/transformers
- TORCH_HOME=/app/cache/torch
- TOKENIZERS_PARALLELISM=false
# Performance Optimization
- PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
- OMP_NUM_THREADS=2
- MKL_NUM_THREADS=2
# Database Configuration
- DATABASE_PATH=/app/data/iranian_legal_archive_advanced.sqlite
- CACHE_DB_PATH=/app/data/cache_system.sqlite
- EMBEDDINGS_CACHE_PATH=/app/data/embeddings_cache.pkl
- VECTOR_INDEX_PATH=/app/data/faiss_index.bin
# Security Settings
- ANTI_DDOS_ENABLED=true
- MAX_REQUESTS_PER_HOUR=100
- REQUEST_DELAY_MIN=1
- REQUEST_DELAY_MAX=5
# Legal Sources Configuration
- CRAWLER_ENABLED=true
- MAX_CRAWL_DEPTH=2
- CRAWL_DELAY_SECONDS=3
volumes:
# Persistent data storage
- persian_legal_data:/app/data
- persian_legal_cache:/app/cache
- persian_legal_logs:/app/logs
- persian_legal_uploads:/app/uploads
# Configuration files (optional)
- ./config:/app/config:ro
networks:
- persian-legal-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7860"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
depends_on:
- redis-cache
# Resource limits for production
deploy:
resources:
limits:
memory: 4G
cpus: '2.0'
reservations:
memory: 2G
cpus: '1.0'
# Redis for Advanced Caching (Optional)
redis-cache:
image: redis:7-alpine
container_name: persian-legal-redis
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- persian_legal_redis_data:/data
networks:
- persian-legal-network
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 3
# Nginx Reverse Proxy (Optional for production)
nginx-proxy:
image: nginx:alpine
container_name: persian-legal-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- persian_legal_logs:/var/log/nginx
networks:
- persian-legal-network
depends_on:
- persian-legal-scraper
profiles:
- production
# Database Backup Service (Optional)
db-backup:
image: alpine:latest
container_name: persian-legal-backup
restart: unless-stopped
command: |
sh -c '
apk add --no-cache sqlite curl
while true; do
echo "Starting backup at $$(date)"
sqlite3 /app/data/iranian_legal_archive_advanced.sqlite ".backup /app/backups/backup_$$(date +%Y%m%d_%H%M%S).sqlite"
find /app/backups -name "backup_*.sqlite" -mtime +7 -delete
echo "Backup completed at $$(date)"
sleep 86400
done
'
volumes:
- persian_legal_data:/app/data:ro
- persian_legal_backups:/app/backups
networks:
- persian-legal-network
profiles:
- production
volumes:
# Persistent data volumes
persian_legal_data:
driver: local
driver_opts:
type: none
o: bind
device: ./data
persian_legal_cache:
driver: local
driver_opts:
type: none
o: bind
device: ./cache
persian_legal_logs:
driver: local
driver_opts:
type: none
o: bind
device: ./logs
persian_legal_uploads:
driver: local
persian_legal_redis_data:
driver: local
persian_legal_backups:
driver: local
networks:
persian-legal-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16