Files
design2garmentcode-impl/Dockerfile
2026-04-17 11:34:05 +08:00

43 lines
1.5 KiB
Docker
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
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_PROJECT_ENVIRONMENT=/app/.venv \
TORCH_CUDA_ARCH_LIST="8.6" \
CUDA_VISIBLE_DEVICES=0 \
UV_TORCH_BACKEND=cu128
COPY --from=uv_bin /uv /uvx /bin/
#RUN apt-get update && apt-get install -y --no-install-recommends \
# ca-certificates curl gnupg && \
# sed -i 's|http://archive.ubuntu.com/ubuntu/|http://mirrors.cloud.tencent.com/ubuntu/|g' /etc/apt/sources.list && \
# sed -i 's|http://security.ubuntu.com/ubuntu/|http://mirrors.cloud.tencent.com/ubuntu/|g' /etc/apt/sources.list && \
# apt-get update && \
# apt-get install -y --no-install-recommends \
# git \
# 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.9
# 4. 拷贝项目文件并安装项目本身
COPY . .
#RUN uv sync --frozen --no-dev --python 3.9
# 5. 【最关键】将虚拟环境的 bin 目录提到最前面
# 注意uv sync 创建的 python 就在这个目录下
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
# 验证路径并运行
# 此时运行 python 实际上是运行 /app/.venv/bin/python
CMD ["sleep", "infinity"]