FROM python:3.10-slim # Install system dependencies RUN apt-get update && apt-get install -y \ tesseract-ocr \ poppler-utils \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy requirements first to leverage Docker cache COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create necessary directories with proper permissions RUN mkdir -p /data/uploads /tmp/huggingface /tmp/torch /tmp/whisper && \ chmod -R 777 /data /tmp # Set environment variables ENV PYTHONUNBUFFERED=1 ENV HF_HOME=/tmp/huggingface ENV TRANSFORMERS_CACHE=/tmp/huggingface ENV XDG_CACHE_HOME=/tmp ENV TORCH_HOME=/tmp/torch ENV WHISPER_CACHE=/tmp/whisper ENV PYTHONPATH=/app # Expose port EXPOSE 7860 # Run the application with gunicorn CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "8", "--timeout", "0", "ai_med_extract.app:app"]