Spaces:
Sleeping
Sleeping
File size: 1,100 Bytes
261c874 68686ca 261c874 68686ca 261c874 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # Use Python 3.9 slim image for efficiency
FROM python:3.9-slim
# Install build dependencies needed for ML packages (chromadb, sentence-transformers, blis)
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
gcc \
g++ \
libc6-dev \
libffi-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for security
RUN useradd -m -u 1000 user
USER user
# Set environment variables
ENV PATH="/home/user/.local/bin:$PATH"
ENV PYTHONPATH="/app:$PYTHONPATH"
# Set working directory
WORKDIR /app
# Copy requirements file with proper ownership
COPY --chown=user requirements.txt requirements.txt
# Install Python dependencies with better wheel support
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir --prefer-binary --upgrade -r requirements.txt
# Copy application code
COPY --chown=user app.py /app/
COPY --chown=user . /app/
# Expose port 7860 for Hugging Face Spaces
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |