From 614da6b7b292a1d58945177037547b7193ab4269 Mon Sep 17 00:00:00 2001 From: zcr Date: Fri, 17 Apr 2026 10:58:39 +0800 Subject: [PATCH] 1 --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 25 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd861a2 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..789cce5 --- /dev/null +++ b/docker-compose.yaml @@ -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 \ No newline at end of file