# Only needed if you run this outside a Gradio Space (locally, or as an # sdk: docker Space). A plain `sdk: gradio` Space builds its own container # from requirements.txt and does not use this file. FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 RUN apt-get update && apt-get install -y --no-install-recommends \ python3.10 python3-pip git && \ rm -rf /var/lib/apt/lists/* # Spaces run as uid 1000 and only $HOME is writable; the model cache must # live somewhere this user can actually write or startup fails. RUN useradd -m -u 1000 app USER app ENV HOME=/home/app \ HF_HOME=/home/app/.cache/huggingface \ PATH=/home/app/.local/bin:$PATH WORKDIR /home/app COPY --chown=app requirements.txt . RUN pip3 install --user --no-cache-dir -r requirements.txt COPY --chown=app app.py ./ COPY --chown=app src/ ./src/ EXPOSE 7860 ENV PORT=7860 CMD ["python3", "app.py"]