This commit is contained in:
zcr
2026-04-17 10:58:39 +08:00
parent 77c76740d4
commit 614da6b7b2
2 changed files with 63 additions and 0 deletions

38
Dockerfile Normal file
View File

@@ -0,0 +1,38 @@
FROM ghcr.io/astral-sh/uv:latest AS uv_bin
FROM nvidia/cuda:12.4.1-runtime-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 \
ffmpeg libsm6 libxext6 \
build-essential g++ \
git \
&& 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"]

25
docker-compose.yaml Normal file
View File

@@ -0,0 +1,25 @@
services:
AiDA_design2garment:
container_name: AiDA_design2garment
build:
context: .
dockerfile: Dockerfile
working_dir: /app
volumes:
- .:/app
ports:
- "10071:8000"
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: [ '1' ]
capabilities:
- gpu
networks:
- lc_app_net
networks:
aida_app_net:
external: true
name: aida_app_net