Spaces:
Running
Running
# Use official Python 3.10 image | |
FROM python:3.10-slim | |
# Install system dependencies (requires root) | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
libgl1 \ | |
build-essential \ | |
curl \ | |
&& apt-get clean && rm -rf /var/lib/apt/lists/* | |
# Create non-root user | |
RUN useradd -m -u 1000 user | |
# Set environment for pip and path | |
ENV PATH="/home/user/.local/bin:$PATH" \ | |
PYTHONDONTWRITEBYTECODE=1 \ | |
PYTHONUNBUFFERED=1 | |
# Switch to the user | |
USER user | |
WORKDIR /app | |
# Copy and install requirements | |
COPY --chown=user requirements.txt . | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir -r requirements.txt | |
# Ensure spaCy model is installed (safe fallback if download fails) | |
RUN python -m spacy download en_core_web_sm || echo "spaCy model download failed, continuing..." | |
# Copy rest of the app | |
COPY --chown=user . . | |
# Expose port (optional but good practice) | |
EXPOSE 7860 | |
# Start the app | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |