diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index a98fa7d..73862c3 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -1,28 +1,26 @@ 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 +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} -# Set USER here? https://stackoverflow.com/questions/24549746/switching-users-inside-docker-image-to-a-non-root-user -# USER ${uid}:${gid} +WORKDIR ${APPLICATION_ROOT} -# RUN --mount=type=cache,target=/root/.cache/pip \ -# put Cache somehwere else or don't define target? -# PIP_CACHE_DIR pip cache dir +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.19 && \ - 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} \ No newline at end of file + +ENTRYPOINT ["./entrypoint.sh"] +CMD python -u main.py --listen --port 7860 ${CLI_ARGS} diff --git a/services/comfy/entrypoint.sh b/services/comfy/entrypoint.sh index b4299a7..f7497dd 100755 --- a/services/comfy/entrypoint.sh +++ b/services/comfy/entrypoint.sh @@ -6,9 +6,9 @@ mkdir -vp /data/config/comfy/custom_nodes declare -A MOUNTS -MOUNTS["/root/.cache"]="/data/.cache" -MOUNTS["${ROOT}/input"]="/data/config/comfy/input" -MOUNTS["${ROOT}/output"]="/output/comfy" +# MOUNTS["/root/.cache"]="/data/.cache" # Determine why the original author decided to do this. +MOUNTS["${APPLICATION_ROOT}/input"]="/data/config/comfy/input" +MOUNTS["${APPLICATION_ROOT}/output"]="/output/comfy" for to_path in "${!MOUNTS[@]}"; do set -Eeuo pipefail @@ -23,7 +23,7 @@ for to_path in "${!MOUNTS[@]}"; do done if [ -f "/data/config/comfy/startup.sh" ]; then - pushd ${ROOT} + pushd ${APPLICATION_ROOT} . /data/config/comfy/startup.sh popd fi diff --git a/services/comfy/extra_model_paths.yaml b/services/comfy/extra_model_paths.yaml index 042c994..d56f207 100644 --- a/services/comfy/extra_model_paths.yaml +++ b/services/comfy/extra_model_paths.yaml @@ -16,6 +16,7 @@ a111: clip: models/CLIPEncoder embeddings: embeddings + # This isn't a real value as far as I can tell? custom_nodes: config/comfy/custom_nodes # TODO: I am unsure about these, need more testing