FROM python:3.10-slim # Install system dependencies (including graphics rendering libs for RDKit) RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ libxrender1 \ libxext6 \ libsm6 \ libice6 \ && rm -rf /var/lib/apt/lists/* # Set up non-root user for Hugging Face Spaces compatibility RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy requirements first for caching COPY --chown=user requirements.txt . # Install CPU PyTorch first to avoid downloading heavy CUDA weights RUN pip install --no-cache-dir torch==2.1.2 --index-url https://download.pytorch.org/whl/cpu # Install remaining dependencies from requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy source code and directories into the container COPY --chown=user app.py . COPY --chown=user dist/ dist/ COPY --chown=user workspace/ workspace/ # Expose the HF Space port EXPOSE 7860 # Run FastAPI app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]