FROM ubuntu:24.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ python3 python3-pip python3-venv \ libgomp1 libstdc++6 curl unzip ca-certificates \ && rm -rf /var/lib/apt/lists/* # HF Spaces recommends running as a non-root user with uid 1000. # ubuntu:24.04 ships a default 'ubuntu' user already holding uid 1000 — drop it first. RUN userdel -r ubuntu 2>/dev/null || true; useradd -m -u 1000 user USER user ENV HOME=/home/user # isolated venv (Ubuntu 24.04 is PEP-668 externally-managed) RUN python3 -m venv /home/user/venv ENV PATH=/home/user/venv/bin:$PATH RUN pip install --no-cache-dir \ "gradio==4.44.1" "fastapi==0.115.4" \ "huggingface_hub>=0.25,<1.0" "requests>=2.31" WORKDIR /home/user/app COPY --chown=user app.py . EXPOSE 7860 CMD ["python3", "app.py"]