Merge pull request #2 from ductiletoaster/revmap-comfyui

Revmap comfyui
This commit is contained in:
Brian Gebel 2025-04-28 14:51:42 -07:00 committed by GitHub
commit c37c3359a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 92 additions and 40 deletions

4
.env.example Normal file
View file

@ -0,0 +1,4 @@
PUID=1000
PGID=1000
DEVICE_DRIVER=nvidia

4
.gitignore vendored
View file

@ -4,3 +4,7 @@
# VSCode specific
*.code-workspace
/.vscode
# Service data
/data/*
!/data/.gitkeep

7
TASK.md Normal file
View file

@ -0,0 +1,7 @@
- [] Update docker-compose to be a more readable
- [] Add support for swarm
- [] Pin / configurable versions
- [] rocm / zluda support
- [] persistant vol for custom extensions
- [] generally better workflow vol mappings
- [] auto custom node loader for comfyui

4
data/.gitignore vendored
View file

@ -1,4 +0,0 @@
/.cache
/config
/embeddings
/models

0
data/.gitkeep Normal file
View file

28
docker-compose.v2.yml Normal file
View file

@ -0,0 +1,28 @@
services:
comfyui:
build: ./services/ComfyUI/
image: comfyui
# user: ${PUID:-1000}:${PGID:-1000}
# environment:
# - PUID=${PUID:-1000}
# - PGID=${PGID:-1000}
# - CLI_ARGS=
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./data:/data
- ./output:/output
ports:
- "7860:7860"
stop_signal: SIGKILL
tty: true
deploy:
resources:
reservations:
devices:
- driver: ${DEVICE_DRIVER:-nvidia}
device_ids: ['0']
capabilities: [compute, utility]
restart: unless-stopped

View file

@ -1,4 +1,8 @@
x-base_service: &base_service
user: ${PUID:-1000}:${PGID:-1000}
environment:
- PUID=${PUID:-1000}
- PGID=${PGID:-1000}
ports:
- "${WEBUI_PORT:-7860}:7860"
volumes:

View file

@ -1,21 +1,29 @@
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
ENV DEBIAN_FRONTEND=noninteractive
ENV PIP_PREFER_BINARY=1
ENV APPLICATION_ROOT=/stable-diffusion
ENV NVIDIA_VISIBLE_DEVICES=all
ENV PYTHONPATH="${PYTHONPATH}:${PWD}"
ENV CLI_ARGS=""
RUN apt-get update && apt-get install -y git && apt-get clean
WORKDIR ${APPLICATION_ROOT}
# Explore how we can use the CLI to do this instead
# https://docs.comfy.org/installation/system_requirements
# https://docs.comfy.org/comfy-cli/getting-started
RUN apt-get update && \
apt-get install -y git && \
apt-get clean && \
git clone --branch v0.3.19 --depth 1 https://github.com/comfyanonymous/ComfyUI.git ${APPLICATION_ROOT}
COPY . .
ENV ROOT=/stable-diffusion
RUN --mount=type=cache,target=/root/.cache/pip \
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
cd ${ROOT} && \
git checkout v0.3.30 && \
pip install -r requirements.txt
pip install -r requirements.txt && \
chmod u+x ./entrypoint.sh
WORKDIR ${ROOT}
COPY . /docker/
RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT}
ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS=""
EXPOSE 7860
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}
ENTRYPOINT ["./entrypoint.sh"]
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}

View file

@ -2,28 +2,24 @@
set -Eeuo pipefail
mkdir -vp /data/config/comfy/custom_nodes
BASE_DIRECTORY="/data/config/comfy"
OUTPUT_DIRECTORY="/data/output"
declare -A MOUNTS
mkdir -vp ${BASE_DIRECTORY}
mkdir -vp ${BASE_DIRECTORY}/temp
mkdir -vp ${BASE_DIRECTORY}/user
mkdir -vp ${BASE_DIRECTORY}/custom_nodes
mkdir -vp ${OUTPUT_DIRECTORY}
MOUNTS["/root/.cache"]="/data/.cache"
MOUNTS["${ROOT}/input"]="/data/config/comfy/input"
MOUNTS["${ROOT}/output"]="/output/comfy"
# --base-directory BASE_DIRECTORY
# Set the ComfyUI base directory for models,
# custom_nodes, input, output, temp, and user directories.
CLI_ARGS+="${CLI_ARGS} --base-directory ${BASE_DIRECTORY} --output-directory ${OUTPUT_DIRECTORY}"
for to_path in "${!MOUNTS[@]}"; do
set -Eeuo pipefail
from_path="${MOUNTS[${to_path}]}"
rm -rf "${to_path}"
if [ ! -f "$from_path" ]; then
mkdir -vp "$from_path"
fi
mkdir -vp "$(dirname "${to_path}")"
ln -sT "${from_path}" "${to_path}"
echo Mounted $(basename "${from_path}")
done
echo ${CLI_ARGS}
if [ -f "/data/config/comfy/startup.sh" ]; then
pushd ${ROOT}
pushd ${APPLICATION_ROOT}
. /data/config/comfy/startup.sh
popd
fi

View file

@ -1,3 +1,4 @@
# https://github.com/comfyanonymous/ComfyUI/blob/master/extra_model_paths.yaml.example
a111:
base_path: /data
@ -16,10 +17,14 @@ a111:
clip: models/CLIPEncoder
embeddings: embeddings
custom_nodes: config/comfy/custom_nodes
comfyui:
base_path: /data
# custom_nodes: config/comfy/custom_nodes
# TODO: I am unsure about these, need more testing
# style_models: config/comfy/style_models
# t2i_adapter: config/comfy/t2i_adapter
# clip_vision: config/comfy/clip_vision
# diffusers: config/comfy/diffusers
# style_models: data/config/comfy/style_models
# t2i_adapter: data/config/comfy/t2i_adapter
# clip_vision: data/config/comfy/clip_vision
# diffusers: data/config/comfy/diffusers
# download_model_base: data/models