glof / Dockerfile
Freate16's picture
Fix PyTorch pip version tags
fb45033
Raw
History Blame Contribute Delete
1.61 kB
# Use a lightweight Python 3.10 base image
FROM python:3.10-slim
# Hugging Face Spaces requires running as a non-root user (UID 1000)
RUN useradd -m -u 1000 user
# Set working directory and change ownership to the non-root user
WORKDIR /app
RUN chown user:user /app
# Switch to the non-root user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONPATH=/app
# Install system dependencies (must switch to root temporarily)
USER root
RUN apt-get update && apt-get install -y \
build-essential \
libgdal-dev \
git \
git-lfs \
&& rm -rf /var/lib/apt/lists/*
USER user
# 1. Install PyTorch FIRST (Required for PyG C++ extensions)
RUN pip install --no-cache-dir --user torch==2.10.0 torchvision==0.25.0 --extra-index-url https://download.pytorch.org/whl/cpu
# 2. Install PyTorch Geometric dependencies (Sparse/Scatter) natively from PyG wheel index
RUN pip install --no-cache-dir --user torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.10.0+cpu.html
# 3. Copy requirements and install the rest (It will skip torch and torch-scatter since they are already installed)
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt -f https://data.pyg.org/whl/torch-2.10.0+cpu.html
# Copy the rest of the application
COPY --chown=user:user . .
# Ensure correct permissions for the Pyoxigraph Knowledge Graph storage
RUN chmod -R 777 /app || true
# Expose port for Hugging Face Spaces
EXPOSE 7860
# Command to run the FastAPI server
CMD ["python", "chatbot/chat_server.py", "--host", "0.0.0.0", "--port", "7860"]