From 79ec1c5300952d85c83cdc73994806247b1ca0a9 Mon Sep 17 00:00:00 2001 From: zcr Date: Tue, 23 Dec 2025 17:05:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Aupdate=20DockerFile=20,replace=20p?= =?UTF-8?q?ip=20with=20uv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 59 +++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ceb011..7d60f8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,33 @@ -# Change CUDA and cuDNN version here +FROM ghcr.io/astral-sh/uv:latest AS uv_bin FROM nvidia/cuda:12.4.1-base-ubuntu22.04 -ARG PYTHON_VERSION=3.10 -ENV DEBIAN_FRONTEND=noninteractive +# 1. 基础环境配置 +ENV UV_LINK_MODE=copy \ + UV_COMPILE_BYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + UV_PROJECT_ENVIRONMENT=/app/.venv + +COPY --from=uv_bin /uv /uvx /bin/ RUN apt-get update && apt-get install -y --no-install-recommends \ - software-properties-common \ wget \ - && add-apt-repository ppa:deadsnakes/ppa \ - && apt-get update && apt-get install -y --no-install-recommends \ - python$PYTHON_VERSION \ - python$PYTHON_VERSION-dev \ - python$PYTHON_VERSION-venv \ - && wget https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ - && python$PYTHON_VERSION get-pip.py \ - && rm get-pip.py \ - && ln -sf /usr/bin/python$PYTHON_VERSION /usr/bin/python \ - && ln -sf /usr/local/bin/pip$PYTHON_VERSION /usr/local/bin/pip \ - && python --version \ - && pip --version \ - && apt-get purge -y --auto-remove software-properties-common \ + libcurl4-openssl-dev \ + build-essential \ + libgl1 \ + libglib2.0-0 \ + ca-certificates \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -####### Add your own installation commands here ####### -# RUN pip install some-package -# RUN wget https://path/to/some/data/or/weights -# RUN apt-get update && apt-get install -y -RUN apt-get update && \ - apt-get install -y libcurl4-openssl-dev build-essential - -RUN apt-get update -RUN apt-get -y install libgl1 -RUN apt-get -y install libglib2.0-0 - - WORKDIR /app -COPY . /app +COPY pyproject.toml uv.lock ./ + +RUN uv sync --frozen --no-dev --no-install-project --python 3.10 + +# 4. 拷贝项目文件并安装项目本身 +COPY . . +RUN uv sync --frozen --no-dev --python 3.10 + +ENV PATH="/app/.venv/bin:$PATH" -# Install litserve and requirements -RUN pip install --upgrade pip setuptools wheel -RUN pip install --no-cache-dir litserve==0.2.16 -r requirements.txt -RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 EXPOSE 8000 -CMD ["python", "-m","app.main"] -#CMD ["tail", "-f","/dev/null"] +CMD ["uv", "run","-m","app.main"]