FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ HF_HOME=/home/user/.cache/huggingface \ TORCH_HOME=/home/user/.cache/torch \ MPLCONFIGDIR=/tmp/matplotlib \ SAM2_BUILD_CUDA=0 RUN apt-get update && apt-get install -y --no-install-recommends \ git \ build-essential \ curl \ libglib2.0-0 \ libgomp1 \ libgl1 \ && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /home/user/app COPY --chown=user requirements.txt /home/user/app/requirements.txt RUN python -m pip install --upgrade pip setuptools wheel # CPU PyTorch for Hugging Face CPU Spaces. RUN python -m pip install \ torch==2.5.1 \ torchvision==0.20.1 \ --index-url https://download.pytorch.org/whl/cpu RUN python -m pip install -r requirements.txt COPY --chown=user . /home/user/app EXPOSE 7860 CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "7860"]