# Use an official NVIDIA CUDA base image with Python FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04 # Install Python and pip RUN apt-get update && apt-get install -y \ python3.9 \ python3-pip \ && ln -s /usr/bin/python3.9 /usr/bin/python \ && apt-get clean # Create and set a non-root user (required by Hugging Face) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH # Set the working directory WORKDIR /home/user/app # Copy requirements and install dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy your FastAPI app code COPY --chown=user ./main.py /home/user/app/main.py # Expose the port Hugging Face Spaces expects EXPOSE 7860 # Run the FastAPI app with Uvicorn CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]