fix: dockerfile
This commit is contained in:
35
Dockerfile
35
Dockerfile
@@ -1,5 +1,5 @@
|
||||
# Use NVIDIA CUDA base image with Python 3.10 (CUDA 12.8 for RTX 5080)
|
||||
FROM nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
|
||||
# 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 \
|
||||
@@ -8,27 +8,33 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
CUDA_VISIBLE_DEVICES=0
|
||||
|
||||
# Install Python 3.10 and system dependencies
|
||||
# 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.10 \
|
||||
python3.10-dev \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
git \
|
||||
libglib2.0-0 \
|
||||
libsm6 \
|
||||
libxext6 \
|
||||
libxrender-dev \
|
||||
libgomp1 \
|
||||
libgl1-mesa-glx \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set Python 3.10 as default
|
||||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
|
||||
# Create symlink for python command
|
||||
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||
|
||||
# Upgrade pip
|
||||
RUN python3 -m pip install --upgrade pip setuptools wheel
|
||||
# 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
|
||||
@@ -37,9 +43,12 @@ WORKDIR /app
|
||||
COPY . /app/
|
||||
|
||||
# Install PyTorch with CUDA support first (cu124 is compatible with CUDA 12.8)
|
||||
RUN pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
|
||||
# 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
|
||||
@@ -56,5 +65,5 @@ 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", "server", "-p", "8001"]
|
||||
CMD ["texteller", "launch", "-p", "8001"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user