Files
LC_NeoRefacer/Dockerfile

37 lines
1.1 KiB
Docker
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM ghcr.io/astral-sh/uv:latest AS uv_bin
FROM nvidia/cuda:12.4.1-base-ubuntu22.04
# 1. 基础环境配置
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PYTHONUNBUFFERED=1 \
# 核心:强制 uv 把虚拟环境建在 /app/.venv
UV_PROJECT_ENVIRONMENT=/app/.venv
COPY --from=uv_bin /uv /uvx /bin/
# 2. 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg libsm6 libxext6 build-essential g++ \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 3. 安装依赖 (不加 --system让 uv 创建受管的虚拟环境)
# 这里会根据 pyproject.toml 自动下载并安装 Python 3.11
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project --python 3.11
# 4. 拷贝项目文件并安装项目本身
COPY . .
RUN uv sync --frozen --no-dev --python 3.11
# 5. 【最关键】将虚拟环境的 bin 目录提到最前面
# 注意uv sync 创建的 python 就在这个目录下
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
# 验证路径并运行
# 此时运行 python 实际上是运行 /app/.venv/bin/python
CMD ["uv", "run","litserver_main.py"]