diff --git a/docker-compose.yml b/docker-compose.yml index 1864239..38253f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -112,7 +112,7 @@ services: - ./data/models:/SwarmUI/Models - ./data/embeddings:/SwarmUI/Models/Embeddings # comfyui - - ./data/config/comfy/custom_nodes:/SwarmUI/dlbackend/ComfyUI/custom_nodes* + - ./data/config/comfy/custom_nodes:/SwarmUI/dlbackend/ComfyUI/custom_nodes # TODO fix permissions - ./data/models/configs:/SwarmUI/dlbackend/ComfyUI/user/default/ # output diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index 783c5d1..af625f1 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -1,5 +1,5 @@ # Defines the versions of ComfyUI, ComfyUI Manager, and PyTorch to use -ARG COMFYUI_VERSION=v0.3.50 +ARG COMFYUI_VERSION=v0.3.52 ARG COMFYUI_MANAGER_VERSION=3.33.8 ARG PYTORCH_VERSION=2.7.1-cuda12.8-cudnn9-runtime @@ -50,12 +50,17 @@ RUN pip3 install --no-cache-dir \ sageattention \ psutil +# Pre-install previously used custom nodes requirements from volume +COPY ./install/merged-requirements.txt* /docker/requirements.txt +RUN sh -c '[ -f /docker/requirements.txt ] && pip install --no-cache-dir -r /docker/requirements.txt \ + || echo "merged-requirements.txt not found, skipping pre-install."' + # Sets the working directory to the ComfyUI directory WORKDIR /opt/comfyui COPY . /docker/ RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml /opt/comfyui -ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS="" +ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="\${PYTHONPATH}:\${PWD}" CLI_ARGS="" EXPOSE 7861 # Adds the startup script to the container; the startup script will create all necessary directories in the models and custom nodes volumes that were diff --git a/services/comfy/install/.gitignore b/services/comfy/install/.gitignore new file mode 100644 index 0000000..c290e5e --- /dev/null +++ b/services/comfy/install/.gitignore @@ -0,0 +1,2 @@ +reqs +merged-requirements.txt diff --git a/services/comfy/install/install.sh b/services/comfy/install/install.sh new file mode 100644 index 0000000..c88b9e6 --- /dev/null +++ b/services/comfy/install/install.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Get custom nodes requirements and merge latest versions +REQ_PATH="data/config/comfy/custom_nodes" +BUILD_PATH="services/comfy/install" + +mkdir -p ${BUILD_PATH}/reqs +for f in ${REQ_PATH}/*/requirements.txt; do \ + node=$(basename $(dirname "$f")); \ + cp "$f" ${BUILD_PATH}/reqs/${node}-requirements.txt; \ +done +find ${BUILD_PATH}/reqs -maxdepth 1 -name "*requirements.txt" -exec cat {} + \ + | grep -v '^#' \ + | grep -v '^git' \ + | sed 's/==.*//' \ + | awk '{print tolower($0)}' \ + | sed 's/[[:space:]]//g' \ + | sort -u \ + | awk ' + { + line = $0; + if (line ~ /^[[:space:]]*$/) { next } + if (line ~ /git\+/ || line ~ /\[.*\]/) { + print "Z_" line, "0", line + next + } + split(line, a, "[<>=]") + package = a[1] + version = a[2] + gsub(/[[:space:]]+/, "", package) + gsub(/_/, "-", package) + if (version == "") { + version = "0" + } + print package, version, line + } + ' \ + | sort -k1,1 -V -k2,2 \ + | awk ' + { + if (prev_package != $1) { + if (NR > 1) { + print prev_line + } + prev_package = $1 + } + prev_line = $3 + } + END { + print prev_line + } + ' \ + > ${BUILD_PATH}/merged-requirements.txt