Spaces:
Build error
Build error
# Use minimal Python image with Intel MKL optimizations | |
FROM python:3.9-slim-bullseye | |
# Configure environment for CPU optimization | |
ENV DEBIAN_FRONTEND=noninteractive \ | |
OMP_NUM_THREADS=4 \ | |
PORT=7860 \ | |
MAX_WORKERS=2 | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
gcc \ | |
libgl1 \ | |
poppler-utils \ | |
&& rm -rf /var/lib/apt/lists/* | |
WORKDIR /app | |
# Install Python dependencies with CPU-optimized versions | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -U pip && \ | |
pip install --no-cache-dir \ | |
-r requirements.txt \ | |
--timeout 600 \ | |
--extra-index-url https://download.pytorch.org/whl/cpu | |
# Copy application files | |
COPY . . | |
# Start the server | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"] | |
# FROM python:3.9-slim | |
# WORKDIR /code | |
# # Hugging Face Space requirements | |
# ENV HF_HOME=/tmp/cache \ | |
# TRANSFORMERS_CACHE=/tmp/cache \ | |
# SENTENCE_TRANSFORMERS_HOME=/tmp/cache \ | |
# PATH="/home/appuser/.local/bin:${PATH}" | |
# # System dependencies | |
# RUN apt-get update && apt-get install -y --no-install-recommends \ | |
# build-essential \ | |
# git \ | |
# && rm -rf /var/lib/apt/lists/* | |
# # Create cache directory and non-root user | |
# RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME} && \ | |
# useradd -m appuser && chown -R appuser /code ${HF_HOME} | |
# USER appuser | |
# # Install Python dependencies | |
# COPY --chown=appuser:appuser requirements.txt . | |
# RUN pip install --no-cache-dir --upgrade pip && \ | |
# pip install --no-cache-dir -r requirements.txt | |
# # Copy application code | |
# COPY --chown=appuser:appuser app.py . | |
# # Hugging Face Space-specific CMD | |
# CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |