Spaces:
Sleeping
Sleeping
File size: 1,025 Bytes
e5aeb10 5173630 e5aeb10 c14ab2c 75749cf e5aeb10 75749cf e5aeb10 c14ab2c e5aeb10 c14ab2c e5aeb10 75749cf e5aeb10 c14ab2c 75749cf |
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 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"]
|