FROM python:3.11-slim WORKDIR /app # Install system dependencies (for numpy/scikit-learn) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Environment variables ENV OPENBLAS_NUM_THREADS=1 ENV OMP_NUM_THREADS=1 ENV PREWARM_CACHE=1 ENV PYTHONUNBUFFERED=1 # Health check HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/health')" || exit 1 # Run with Gunicorn CMD ["gunicorn", "app:app", \ "--workers", "4", \ "--timeout", "120", \ "--bind", "0.0.0.0:5000", \ "--access-logfile", "-", \ "--error-logfile", "-"]