From d4df3d919fccfa88ef3333a0f59245cb40e80223 Mon Sep 17 00:00:00 2001 From: xinanwang Date: Thu, 27 Feb 2025 17:18:40 +0800 Subject: [PATCH] add docker config file --- Dockerfile | 12 ++++++++++++ comfyui.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Dockerfile create mode 100644 comfyui.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..80106efc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# 替换为自己的python镜像地址 +FROM registry.cn-hangzhou.aliyuncs.com/wxa/python:3.12 +# 设置工作目录 +WORKDIR /app +# 复制 requirements.txt 和安装依赖 +COPY requirements.txt /app/requirements.txt +# 安装依赖,指定阿里镜像源 +RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ -r /app/requirements.txt +# 复制源代码到容器内 +COPY . /app +# 设置容器的默认命令 +CMD ["python", "main.py"] \ No newline at end of file diff --git a/comfyui.yaml b/comfyui.yaml new file mode 100644 index 00000000..f1cd6856 --- /dev/null +++ b/comfyui.yaml @@ -0,0 +1,42 @@ +# 配置docker配置文件启用gpu +#{ +# "runtimes": { +# "nvidia": { +# "args": [], +# "path": "nvidia-container-runtime" +# } +# } +#} +# 打包启动镜像命令:docker compose build up -d + +version: '1' + +services: + app: + build: . + container_name: comfyui + runtime: nvidia + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [ gpu ] + + volumes: + - .:/app + - ./app/models/Stable-diffusion:/app/models/Stable-diffusion # 绑定模型目录 + ports: + - "8188:8188" # 如果你的应用需要暴露端口 + command: python main.py # 启动 main.py 文件 + environment: + - PYTHONUNBUFFERED=1 # 确保输出不会被缓冲 + working_dir: /app + restart: always + + networks: + - my_custom_network +networks: + my_custom_network: + name: comfyui \ No newline at end of file