FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ git wget unzip ca-certificates python3 python3-pip python3-venv \ libgl1 libglib2.0-0 && \ rm -rf /var/lib/apt/lists/* RUN useradd user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app COPY --chown=user ./ $HOME/app # Copy app files COPY requirements.txt ./ RUN pip3 install --no-cache-dir -r requirements.txt # Clone RETFound code (for model definitions) RUN git clone https://github.com/rmaphoh/RETFound_MAE $HOME/app/RETFound_MAE # Copy the rest COPY . . # Expose FastAPI default port for Spaces ENV PORT=7860 # HF auth picked automatically from env (Spaces provides HF_TOKEN) ENV HF_HOME=/root/.cache/huggingface \ TRANSFORMERS_CACHE=/root/.cache/huggingface/transformers \ TORCH_HOME=/root/.cache/torch # Start API CMD ["bash", "startup.sh"]