Spaces:
Sleeping
Sleeping
File size: 1,116 Bytes
c7003e9 | 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 | # --- Base Build Stage ---
FROM python:3.11-slim
# Create a non-root user specifically for Hugging Face (User ID 1000)
RUN useradd -m -u 1000 user
USER user
# Set environment variables
ENV PATH="/home/user/.local/bin:$PATH"
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install system dependencies required by OpenCV and PyTorch image handling
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
USER user
# Work from the repository root so the backend package imports resolve correctly
WORKDIR /app
# Install Python dependencies from the backend package
COPY --chown=user ./backend/requirements.txt /app/backend/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/backend/requirements.txt
# Copy the backend package into the image
COPY --chown=user ./backend /app/backend
# Expose the specific port Hugging Face requires
EXPOSE 7860
# Launch the FastAPI server from the backend package
CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"] |