FROM python:3.11-slim WORKDIR /app # 1. Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ cmake \ curl \ git \ libopenblas-dev \ liblapack-dev \ && rm -rf /var/lib/apt/lists/* # 2. CRITICAL FIX: Limit build to 1 thread to prevent OOM (Exit 137) ENV CMAKE_BUILD_PARALLEL_LEVEL=1 # 3. Install dlib separately first RUN pip3 install --no-cache-dir dlib # 4. Install remaining dependencies COPY requirements.txt ./ RUN pip3 install --no-cache-dir -r requirements.txt # 5. Copy source code & startapplicatio.sh script COPY src/ ./src/ COPY startapplication.sh ./ # Make the script executable RUN chmod +x startapplication.sh # 6. Hugging Face Spaces Config EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["./startapplication.sh"]