Spaces:
Sleeping

clearcut-api / Dockerfile
BhavyaPatel07's picture
Update Dockerfile
969d760 verified
Raw History Blame Contribute Delete
1.07 kB
FROM python:3.10-slim
# Install system dependencies needed for OpenCV / Pillow / Scipy
RUN apt-get update && apt-get install -y \
build-essential \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Create user with UID 1000 for Hugging Face Spaces compatibility
RUN useradd -m -u 1000 user
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
ENV U2NET_HOME=/home/user/.u2net
WORKDIR /home/user/app
# Change ownership of working directory to user
RUN chown -R user:user /home/user
# Switch to the non-root user
USER user
# Copy requirements and install
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Pre-download the birefnet-general-lite model so the first request is instant
RUN python -c "from rembg import new_session; new_session('birefnet-general-lite')"
# Copy the rest of the application
COPY --chown=user . .
# Expose port 7860 (Hugging Face Spaces default port)
EXPOSE 7860
# Run Flask on port 7860
CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=7860"]