Skip to content

Commit fcd5ce5

Browse files
author
lesca
committed
+comfyui
1 parent b4698cc commit fcd5ce5

13 files changed

Lines changed: 376 additions & 3 deletions
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Reference: Multi-platform image with GitHub Actions
2+
# https://docs.docker.com/build/ci/github-actions/multi-platform/
3+
# https://docs.docker.com/build/ci/github-actions/push-multi-registries/
4+
5+
name: docker-image-comfyui
6+
concurrency: deploy-${{ github.workflow }}
7+
8+
on:
9+
push:
10+
branches:
11+
- '*'
12+
paths:
13+
- comfyui/Dockerfile
14+
- comfyui/entrypoint.sh
15+
workflow_dispatch:
16+
schedule:
17+
- cron: ' 0 20 * * 5'
18+
19+
env:
20+
IMAGE_CONTEXT: ./comfyui
21+
REGISTRY_IMAGE: ${{ github.repository_owner }}/comfyui
22+
BUILD_PLATFORMS: |
23+
linux/amd64
24+
25+
jobs:
26+
check-updates:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
remote_version: ${{ steps.remote_version.outputs.remote_version }}
30+
steps:
31+
# 1. 获取远程版本
32+
- name: Get remote version
33+
id: remote_version
34+
run: |
35+
REMOTE_REPO="comfyanonymous/ComfyUI"
36+
# 使用 GitHub CLI 或 curl/jq 获取最新 Release Tag
37+
LATEST_TAG=$(curl -s "https://api.github.com/repos/${REMOTE_REPO}/releases/latest" | jq -r .tag_name)
38+
39+
if [ "$LATEST_TAG" = "null" ]; then
40+
echo "::error::Could not find latest release tag."
41+
exit 1
42+
fi
43+
44+
echo "Remote Version: $LATEST_TAG"
45+
echo "remote_version=$LATEST_TAG" >> $GITHUB_OUTPUT
46+
47+
48+
build-images:
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: read
52+
packages: write
53+
needs:
54+
- check-updates
55+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
56+
steps:
57+
- name: Prepare
58+
run: |
59+
echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV
60+
echo "TODAY: $TODAY"
61+
62+
- name: Maximize build space
63+
uses: easimon/maximize-build-space@master
64+
with:
65+
build-mount-path: '/var/lib/docker/'
66+
root-reserve-mb: 512
67+
temp-reserve-mb: 32
68+
swap-size-mb: 32
69+
remove-dotnet: 'true'
70+
remove-android: 'true'
71+
remove-haskell: 'true'
72+
remove-codeql: 'true'
73+
remove-docker-images: 'true'
74+
- name: Restart docker
75+
run: sudo service docker restart
76+
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Login to Docker Hub
81+
uses: docker/login-action@v3
82+
with:
83+
username: ${{ github.repository_owner }}
84+
password: ${{ secrets.DOCKERHUB_TOKEN }}
85+
86+
- name: Login to GitHub Container Registry
87+
uses: docker/login-action@v3
88+
with:
89+
registry: ghcr.io
90+
username: ${{ github.repository_owner }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Set up QEMU
94+
uses: docker/setup-qemu-action@v3
95+
96+
- name: Set up Docker Buildx
97+
uses: docker/setup-buildx-action@v3
98+
99+
- name: Build slim images
100+
id: build
101+
uses: docker/build-push-action@v6
102+
with:
103+
platforms: ${{ env.BUILD_PLATFORMS }}
104+
context: ${{ env.IMAGE_CONTEXT }}
105+
file: ${{ env.IMAGE_CONTEXT }}/Dockerfile
106+
tags: |
107+
${{ env.REGISTRY_IMAGE }}:latest
108+
${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-slim-${{ env.TODAY }}
109+
ghcr.io/${{ env.REGISTRY_IMAGE }}:latest
110+
ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-slim-${{ env.TODAY }}
111+
push: true
112+
build-args: |
113+
VERSION=${{ needs.check-updates.outputs.remote_version }}
114+
BUILD_MODE=slim
115+
116+
- name: Build pro images
117+
id: build
118+
uses: docker/build-push-action@v6
119+
with:
120+
platforms: ${{ env.BUILD_PLATFORMS }}
121+
context: ${{ env.IMAGE_CONTEXT }}
122+
file: ${{ env.IMAGE_CONTEXT }}/Dockerfile
123+
tags: |
124+
${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-pro-${{ env.TODAY }}
125+
ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-pro-${{ env.TODAY }}
126+
push: true
127+
build-args: |
128+
VERSION=${{ needs.check-updates.outputs.remote_version }}
129+
BUILD_MODE=pro

.github/workflows/index-tts-docker.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ jobs:
101101
platforms: ${{ env.BUILD_PLATFORMS }}
102102
context: ${{ env.IMAGE_CONTEXT }}
103103
file: ${{ env.IMAGE_CONTEXT }}/Dockerfile
104-
labels: ${{ steps.meta.outputs.labels }}
105104
tags: |
106105
${{ env.REGISTRY_IMAGE }}:latest
107106
${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-${{ env.TODAY }}

.github/workflows/xray-tproxy-docker.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
paths:
1212
- xray-tproxy/Dockerfile
1313
- xray-tproxy/entrypoint.sh
14-
- .github/workflows/xray-tproxy-docker.yaml
1514
workflow_dispatch:
1615

1716
env:
@@ -104,7 +103,6 @@ jobs:
104103
platforms: ${{ env.BUILD_PLATFORMS }}
105104
context: ${{ env.IMAGE_CONTEXT }}
106105
file: ${{ env.IMAGE_CONTEXT }}/Dockerfile
107-
labels: ${{ steps.meta.outputs.labels }}
108106
tags: |
109107
${{ env.REGISTRY_IMAGE }}:latest
110108
${{ env.REGISTRY_IMAGE }}:${{ needs.check-updates.outputs.remote_version }}-${{ env.TODAY }}

comfyui/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data

comfyui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data

comfyui/Dockerfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04 AS builder
2+
3+
WORKDIR /app
4+
ARG VERSION
5+
ARG BUILD_MODE
6+
7+
ENV CUDA_HOME=/usr/local/cuda \
8+
VIRTUAL_ENV=/app/venv \
9+
PYTHONPYCACHEPREFIX="/root/.cache/pycache"
10+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
11+
12+
# install system dependencies
13+
RUN --mount=type=cache,target=/var/cache/apt/archives,sharing=locked \
14+
apt update \
15+
&& apt install -y --no-install-recommends git curl python3 python3-dev python3-pip python3-venv \
16+
&& rm -rf /var/lib/apt/lists/* \
17+
&& python3 -m venv $VIRTUAL_ENV
18+
19+
# install comfyui dependencies and tools
20+
# https://github.com/Comfy-Org/comfy-cli
21+
RUN --mount=type=cache,target=/root/.cache/pip \
22+
pip install -U pip \
23+
&& pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128 \
24+
&& pip install comfy-cli \
25+
&& comfy --skip-prompt --no-enable-telemetry --here install --nvidia \
26+
&& mkdir -p /app/ComfyUI/user/default/ComfyUI-Manager \
27+
&& cat <<EOF > /app/ComfyUI/user/default/ComfyUI-Manager/config.ini
28+
[default]
29+
use_uv = False
30+
network_mode = offline
31+
EOF
32+
33+
# build Saga Attention
34+
WORKDIR /build/SageAttention
35+
ENV TORCH_CUDA_ARCH_LIST="7.0 7.5 8.0 8.6 9.0"
36+
RUN git clone --depth 1 --branch v2.2.0 https://github.com/thu-ml/SageAttention.git /build/SageAttention \
37+
&& export EXT_PARALLEL=4 NVCC_APPEND_FLAGS="--threads 8" MAX_JOBS=16 \
38+
&& python setup.py install
39+
40+
# install custom nodes
41+
WORKDIR /app/ComfyUI/custom_nodes
42+
COPY nodes nodes
43+
RUN nodes_list=$(sed -e '/^#/d' -e '/^$/d' -e 's/\s*#.*$//' nodes/nodes-${BUILD_MODE}.txt) \
44+
&& for node in $nodes_list; do \
45+
git clone --depth=1 --no-tags --recurse-submodules --shallow-submodules "https://github.com/$node"; \
46+
done
47+
48+
# install custom nodes dependencies
49+
# https://github.com/Comfy-Org/ComfyUI-Manager/blob/main/docs/en/cm-cli.md
50+
RUN --mount=type=cache,target=/root/.cache/pip \
51+
python /app/ComfyUI/custom_nodes/ComfyUI-Manager/cm-cli.py restore-dependencies \
52+
&& nodes_deps=$(sed -e '/^#/d' -e '/^$/d' -e 's/\s*#.*$//' nodes/deps-${BUILD_MODE}.txt) \
53+
&& for dep in $nodes_deps; do \
54+
pip install $dep; \
55+
done \
56+
&& rm -rf nodes
57+
58+
59+
FROM ubuntu:24.04
60+
61+
WORKDIR /app
62+
63+
ENV CUDA_HOME=/usr/local/cuda \
64+
VIRTUAL_ENV=/app/venv \
65+
PYTHONPYCACHEPREFIX="/root/.cache/pycache"
66+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
67+
68+
RUN --mount=type=cache,target=/var/cache/apt/archives,sharing=locked \
69+
apt update \
70+
&& apt install -y --no-install-recommends \
71+
git python3 python3-pip python3-venv ffmpeg rsync aria2 \
72+
&& rm -rf /var/lib/apt/lists/*
73+
74+
COPY --from=builder /app /app
75+
COPY entrypoint.sh /app/entrypoint.sh
76+
77+
EXPOSE 8188
78+
ENTRYPOINT ["/app/entrypoint.sh"]

comfyui/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
## How to use
3+
4+
Please find the [docker-compose.yaml](docker-compose.yaml) file in this repository as a reference.
5+
6+
### Required Models
7+
8+
* VAE Approximation
9+
* https://github.com/madebyollin/taesd/raw/main/taesdxl_decoder.pth
10+
* https://github.com/madebyollin/taesd/raw/main/taesd_decoder.pth
11+
* https://github.com/madebyollin/taesd/raw/main/taesd3_decoder.pth
12+
* https://github.com/madebyollin/taesd/raw/main/taef1_decoder.pth

comfyui/docker-compose.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
comfyui:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
container_name: comfyui
7+
image: comfyui:latest
8+
stop_signal: SIGKILL
9+
# environment:
10+
# - HF_ENDPOINT=https://hf-mirror.com
11+
# - GITHUB_ENDPOINT=https://gh-proxy.com
12+
13+
# GPU
14+
deploy:
15+
resources:
16+
reservations:
17+
devices:
18+
- driver: nvidia
19+
count: 1
20+
capabilities: [gpu]
21+
22+
volumes:
23+
- ./data/models/models:/models
24+
- ./data/models/huggingface:/root/.cache/huggingface
25+
- ./data/models/torch:/root/.cache/torch
26+
- ./data/input:/app/ComfyUI/input
27+
- ./data/output:/app/ComfyUI/output
28+
- ./data/workflows:/app/ComfyUI/user/default/workflows
29+
30+
ports:
31+
- "8188:8188"

comfyui/entrypoint.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/bash
2+
PORT=${PORT:-8188}
3+
COMFYIUI_PATH=/app/ComfyUI
4+
5+
# Backup original directory
6+
if [ -d "/models" ]; then
7+
echo "[INFO] Moving models to /models..."
8+
rsync -a $COMFYIUI_PATH/models/ /models/
9+
fi
10+
11+
# create symlink
12+
if [ ! -L "$COMFYIUI_PATH/models" ]; then
13+
rm -rf $COMFYIUI_PATH/models
14+
ln -s /models $COMFYIUI_PATH/models
15+
fi
16+
17+
if [ "$#" -eq 0 ]; then
18+
echo "[INFO] Starting ComfyUI..."
19+
python $COMFYIUI_PATH/main.py --listen --port $PORT
20+
else
21+
exec "$@"
22+
fi

comfyui/nodes/deps-pro.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
compel # shiimizu/ComfyUI_smZNodes
2+
https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.2/nunchaku-1.0.2+torch2.9-cp312-cp312-linux_x86_64.whl # nunchaku-tech/ComfyUI-nunchaku

0 commit comments

Comments
 (0)