feat:update DockerFile ,replace pip with uv
This commit is contained in:
59
Dockerfile
59
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
|
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 \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
software-properties-common \
|
|
||||||
wget \
|
wget \
|
||||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
libcurl4-openssl-dev \
|
||||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
build-essential \
|
||||||
python$PYTHON_VERSION \
|
libgl1 \
|
||||||
python$PYTHON_VERSION-dev \
|
libglib2.0-0 \
|
||||||
python$PYTHON_VERSION-venv \
|
ca-certificates \
|
||||||
&& 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 \
|
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& 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 <package-name>
|
|
||||||
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
|
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
|
EXPOSE 8000
|
||||||
CMD ["python", "-m","app.main"]
|
CMD ["uv", "run","-m","app.main"]
|
||||||
#CMD ["tail", "-f","/dev/null"]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user