Spaces:
Sleeping
Sleeping
File size: 1,128 Bytes
bf132d0 76e40b0 bf132d0 | 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 | # Use an official Python runtime as a parent image
FROM python:3.10-slim
# Install system dependencies for OpenCV and YOLO
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*
# Set the working directory to /code
WORKDIR /code
# Copy the requirements file into the container
COPY ./requirements.txt /code/requirements.txt
# Install dependencies
RUN pip install --no-cache-dir -r /code/requirements.txt
# Set up a non-root user named "user" with user ID 1000
# Hugging Face Spaces requires the container to run as a non-root user for security
RUN useradd -m -u 1000 user
USER user
# Set environment variables for the user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Change the working directory to the user's home app directory
WORKDIR $HOME/app
# Copy all the files into the container at $HOME/app, owned by the new user
COPY --chown=user . $HOME/app
# Expose port 7860 (The default expected by Hugging Face Spaces)
EXPOSE 7860
# Command to run the Fastapi application using uvicorn on port 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|