Spaces:
Paused
Paused
| FROM python:3.11-slim | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| DEBIAN_FRONTEND=noninteractive | |
| WORKDIR /app | |
| # Install system dependencies (minimal set) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| tesseract-ocr \ | |
| poppler-utils \ | |
| ffmpeg \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy and install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt uvicorn[standard] | |
| # Copy application code | |
| COPY . . | |
| # Set environment for HF Spaces with minimal resource usage | |
| ENV PYTHONPATH=/app/services/ai-service/src:$PYTHONPATH \ | |
| HF_SPACES=true \ | |
| FAST_MODE=true \ | |
| PRELOAD_SMALL_MODELS=false \ | |
| PRELOAD_GGUF=false \ | |
| HF_HOME=/tmp/huggingface \ | |
| TORCH_HOME=/tmp/torch \ | |
| WHISPER_CACHE=/tmp/whisper \ | |
| MODEL_CACHE_DIR=/tmp/models \ | |
| TRANSFORMERS_CACHE=/tmp/huggingface/transformers \ | |
| PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128 \ | |
| TOKENIZERS_PARALLELISM=false \ | |
| OMP_NUM_THREADS=1 \ | |
| MKL_NUM_THREADS=1 | |
| # Create necessary directories | |
| RUN mkdir -p /tmp/uploads /tmp/huggingface /tmp/models && \ | |
| chmod -R 777 /tmp | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Start application with single worker for minimal memory footprint | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "1200"] | |