# Use NVIDIA CUDA base image with Python 3.12 (CUDA 12.8 for RTX 5080) FROM nvidia/cuda:12.8.0-base-ubuntu24.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ CUDA_VISIBLE_DEVICES=0 # Configure apt to use Tsinghua mirror (清华源) RUN sed -i 's@//archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources && \ sed -i 's@//security.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources # Install Python and system dependencies (Ubuntu 24.04 uses Python 3.12) RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ python3-venv \ git \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ wget \ && rm -rf /var/lib/apt/lists/* # Create symlink for python command RUN ln -sf /usr/bin/python3 /usr/bin/python # Configure pip to use Tsinghua mirror (清华源) and allow system-wide installs RUN python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \ python3 -m pip config set global.break-system-packages true # Upgrade pip (ignore system-installed packages) RUN pip install --upgrade --ignore-installed pip setuptools wheel # Set working directory WORKDIR /app # Copy project files COPY . /app/ # Install PyTorch with CUDA support first (cu124 is compatible with CUDA 12.8) # Note: PyTorch uses official mirror as Tsinghua doesn't host CUDA builds RUN pip install torch torchvision # Install the package and dependencies # Set version manually since .git is excluded by .dockerignore ENV SETUPTOOLS_SCM_PRETEND_VERSION=1.0.0 RUN pip install -e . # Install additional dependencies for server RUN pip install requests # Expose port for Ray Serve EXPOSE 8001 # Create cache directory for models RUN mkdir -p /root/.cache/huggingface/hub # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python3 -c "import requests; requests.get('http://localhost:8001/', timeout=5)" || exit 1 # Default command to start the server (port 8001) CMD ["texteller", "launch", "-p", "8001"]