diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index d9325ef..0df273f 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -2,42 +2,42 @@ FROM alpine:3.17 as xformers RUN apk add --no-cache aria2 RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl' -FROM python:3.10.10-slim + +FROM python:3.10.9-slim ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 -RUN --mount=type=cache,target=/root/.cache/pip pip install torch==1.13.1+cu117 torchvision --extra-index-url https://download.pytorch.org/whl/cu117 +RUN --mount=type=cache,target=/root/.cache/pip pip install torch==1.13.1 torchvision --extra-index-url https://download.pytorch.org/whl/cu117 RUN apt-get update && apt-get install -y git && apt-get clean +ENV ROOT=/stable-diffusion RUN --mount=type=cache,target=/root/.cache/pip \ - git clone https://github.com/comfyanonymous/ComfyUI.git stable-diffusion && \ - cd stable-diffusion && \ + git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \ + cd ${ROOT} && \ git checkout master && \ git reset --hard 884ea653c8d6fe19b3724f45a04a0d74cd881f2f && \ pip install -r requirements.txt + RUN --mount=type=cache,target=/root/.cache/pip \ - --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.15-cp310-cp310-linux_x86_64.whl \ - pip install triton /xformers-0.0.15-cp310-cp310-linux_x86_64.whl + --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.17-cp310-cp310-linux_x86_64.whl \ + pip install triton /xformers-0.0.17-cp310-cp310-linux_x86_64.whl + + +WORKDIR ${ROOT} ARG BRANCH=master SHA=884ea653c8d6fe19b3724f45a04a0d74cd881f2f RUN --mount=type=cache,target=/root/.cache/pip \ - cd stable-diffusion && \ git fetch && \ git checkout ${BRANCH} && \ git reset --hard ${SHA} && \ pip install -r requirements.txt -RUN --mount=type=cache,target=/root/.cache/pip pip install -U 'transformers>=4.24' - # add info COPY . /docker/ -RUN chmod +x /docker/entrypoint.sh -WORKDIR /stable-diffusion -ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility -ENV NVIDIA_VISIBLE_DEVICES=all +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility NVIDIA_VISIBLE_DEVICES=all ENV PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS="" EXPOSE 7860 ENTRYPOINT ["/docker/entrypoint.sh"] diff --git a/services/comfy/entrypoint.sh b/services/comfy/entrypoint.sh index 7703607..5eee352 100644 --- a/services/comfy/entrypoint.sh +++ b/services/comfy/entrypoint.sh @@ -4,26 +4,33 @@ set -Eeuo pipefail declare -A MOUNTS -ROOT=/stable-diffusion + +mkdir -vp /data/config/comfy/ # 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/config/auto/extensions/sd-webui-controlnet/models" -MOUNTS["${ROOT}/models/custom_nodes"]="/data/comfy/custom_nodes" -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/controlnet"]="/data/ControlNet" MOUNTS["${ROOT}/models/upscale_models/RealESRGAN"]="/data/RealESRGAN" -MOUNTS["${ROOT}/models/upscale_models/SwinIR"]="/data/SwinIR" MOUNTS["${ROOT}/models/upscale_models/GFPGAN"]="/data/GFPGAN" +MOUNTS["${ROOT}/models/upscale_models/SwinIR"]="/data/SwinIR" MOUNTS["${ROOT}/models/vae"]="/data/VAE" -MOUNTS["${ROOT}/output"]="/output" +# data +MOUNTS["${ROOT}/models/loras"]="/data/Lora" +MOUNTS["${ROOT}/models/embeddings"]="/data/embeddings" + +# config +# TODO: I am not sure if this is final, maybe it should change in the future +MOUNTS["${ROOT}/models/clip"]="/data/config/comfy/clip" +MOUNTS["${ROOT}/models/clip_vision"]="/data/config/comfy/clip_vision" +MOUNTS["${ROOT}/models/custom_nodes"]="/data/config/comfy/custom_nodes" +MOUNTS["${ROOT}/models/style_models"]="/data/config/comfy/style_models" +MOUNTS["${ROOT}/models/t2i_adapter"]="/data/config/comfy/t2i_adapter" + +# output +MOUNTS["${ROOT}/output"]="/output/comfy" for to_path in "${!MOUNTS[@]}"; do set -Eeuo pipefail