Add ComfyUI service.

This commit is contained in:
Jonathan Kovacs 2023-03-16 17:04:19 -04:00
parent 063665eae1
commit 3becc055b3
5 changed files with 79 additions and 0 deletions

View file

@ -11,3 +11,4 @@ Closes issue #
- auto: https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/
- sygil: https://github.com/Sygil-Dev/sygil-webui/commit/
- invoke: https://github.com/invoke-ai/InvokeAI/commit/
- comfy: https://github.com/comfyanonymous/ComfyUI/commit/

View file

@ -16,6 +16,7 @@ jobs:
- auto
- sygil
- invoke
- comfy
- download
runs-on: ubuntu-latest
name: ${{ matrix.profile }}

View file

@ -63,3 +63,11 @@ services:
profiles: ["sygil-sl"]
environment:
- USE_STREAMLIT=1
comfy: &comfy
<<: *base_service
profiles: ["comfy"]
build: ./services/comfy/
image: sd-comfy:1
environment:
- CLI_ARGS=

35
services/comfy/Dockerfile Normal file
View file

@ -0,0 +1,35 @@
# syntax=docker/dockerfile:1
FROM python:3.10.9-slim
SHELL ["/bin/bash", "-ceuxo", "pipefail"]
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
RUN --mount=type=cache,target=/root/.cache/pip pip install torch==1.13.0 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
RUN apt-get update && apt install fonts-dejavu-core rsync git jq moreutils -y && apt-get clean
ARG BRANCH=master SHA=ee46bef03a98903831c01d31094a0c30ea411b28
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
git config --global http.postBuffer 1048576000
git clone https://github.com/comfyanonymous/ComfyUI.git stable-diffusion
cd stable-diffusion
git checkout ${BRANCH}
git reset --hard ${SHA}
pip install -r requirements.txt
EOF
RUN --mount=type=cache,target=/root/.cache/pip pip install -U 'transformers>=4.24'
# add info
COPY . /docker/
RUN <<EOF
chmod +x /docker/entrypoint.sh
EOF
WORKDIR /stable-diffusion
ENV PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS=""
EXPOSE 7860
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}

View file

@ -0,0 +1,34 @@
#!/bin/bash
set -Eeuo pipefail
declare -A MOUNTS
ROOT=/stable-diffusion
# cache
MOUNTS["/root/.cache"]=/data/.cache
# ui specific
MOUNTS["${ROOT}/models/checkpoints"]="/data/StableDiffusion"
MOUNTS["${ROOT}/models/clip"]="/data/comfy/clip"
MOUNTS["${ROOT}/models/clip_vision"]="/data/comfy/clip_vision"
MOUNTS["${ROOT}/models/controlnet"]="/data/comfy/controlnet"
MOUNTS["${ROOT}/models/embeddings"]="/data/embeddings"
MOUNTS["${ROOT}/models/loras"]="/data/Lora"
MOUNTS["${ROOT}/models/style_models"]="/data/comfy/style_models"
MOUNTS["${ROOT}/models/t2i_adapter"]="/data/comfy/t2i_adapter"
MOUNTS["${ROOT}/models/upscale_models"]="/data/comfy/upscale_models"
MOUNTS["${ROOT}/models/vae"]="/data/VAE"
MOUNTS["${ROOT}/output"]="/output/comfy"
for to_path in "${!MOUNTS[@]}"; do
set -Eeuo pipefail
from_path="${MOUNTS[${to_path}]}"
rm -rf "${to_path}"
mkdir -p "$(dirname "${to_path}")"
ln -sT "${from_path}" "${to_path}"
echo Mounted $(basename "${from_path}")
done
exec "$@"