Files
stable-diffusion-webui-docker/services/comfy/Dockerfile

109 lines
4.2 KiB
Docker
Raw Normal View History

feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
# Limited system user UID
ARG USE_UID=0
# Limited system user GID
ARG USE_GID=0
# System user name
ARG USE_USER=root
# System group name
ARG USE_GROUP=root
# Latest tag or bleeding edge commit
ARG USE_EDGE=false
# ComfyUI-GGUF
ARG USE_GGUF=false
# x-flux-comfyui
ARG USE_XFLUX=false
# comfyui_controlnet_aux
ARG USE_CNAUX=false
# krita-ai-diffusion
ARG USE_KRITA=false
# ComfyUI_IPAdapter_plus
ARG USE_IPAPLUS=false
# comfyui-inpaint-nodes
ARG USE_INPAINT=false
# comfyui-tooling-nodes
ARG USE_TOOLING=false
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
ENV USE_CNAUX=$USE_CNAUX USE_IPAPLUS=$USE_IPAPLUS
ENV USE_INPAINT=$USE_INPAINT USE_TOOLING=$USE_TOOLING
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 USE_EDGE=$USE_EDGE
ENV USE_GGUF=$USE_GGUF USE_XFLUX=$USE_XFLUX ROOT=/stable-diffusion
ENV CACHE=/home/$USE_USER/.cache USE_KRITA=$USE_KRITA
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
RUN mkdir -p ${ROOT} ${CACHE}/pip /home/${USE_USER}
# User/Group
RUN if [ ${USE_GID} -ne 0 ]; then \
groupadd -r ${USE_GROUP} -g ${USE_GID}; \
fi; \
if [ ${USE_GID} -ne 0 ]; then \
useradd --no-log-init -m -r -g ${USE_GROUP} ${USE_USER} -u ${USE_UID}; \
fi; \
chown -R ${USE_UID}:${USE_GID} ${ROOT} ${CACHE} /home/${USE_USER}
RUN apt-get update && apt-get install -y git python3-pip
RUN if [ "${USE_XFLUX}" = "true" ] || [ "${USE_KRITA}" = "true" ] || [ "${USE_CNAUX}" = "true" ]; then \
apt-get install -y libgl1-mesa-glx python3-opencv; \
fi
RUN apt-get clean
USER ${USE_USER}:${USE_GROUP}
ENV PATH="${PATH}:/home/${USE_USER}/.local/bin"
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} pip --cache-dir=${CACHE}/pip install -U pip
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} \
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
cd ${ROOT} && \
git checkout master && \
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
bash -c 'VERSION=$(git describe --tags --abbrev=0) && \
if [ "${USE_EDGE}" = "true" ]; then VERSION=$(git describe --abbrev=7); fi && \
git reset --hard ${VERSION}' && \
pip --cache-dir=${CACHE}/pip install -r requirements.txt && \
if [ "${USE_KRITA}" = "true" ]; then \
git clone https://github.com/Acly/krita-ai-diffusion.git && \
cd krita-ai-diffusion && git checkout main && \
git submodule update --init && \
pip --cache-dir=${CACHE}/pip install aiohttp tqdm && cd ..; \
fi; \
if [ "${USE_GGUF}" = "true" ]; then \
git clone https://github.com/city96/ComfyUI-GGUF.git && \
cd ComfyUI-GGUF && git checkout main && \
pip --cache-dir=${CACHE}/pip install -r requirements.txt && cd ..; \
fi; \
if [ "${USE_XFLUX}" = "true" ]; then \
git clone https://github.com/XLabs-AI/x-flux-comfyui.git && \
cd x-flux-comfyui && git checkout main && \
pip --cache-dir=${CACHE}/pip install -r requirements.txt && cd ..; \
fi; \
if [ "${USE_CNAUX}" = "true" ] || [ "${USE_KRITA}" = "true" ]; then \
git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git && \
cd comfyui_controlnet_aux && git checkout main && \
pip --cache-dir=${CACHE}/pip install -r requirements.txt && \
# This extra step to separate onnxruntime installation is required to restore onnx cuda support \
pip --cache-dir=${CACHE}/pip install onnxruntime && pip --cache-dir=${CACHE}/pip install onnxruntime-gpu && cd ..; \
fi; \
if [ "${USE_IPAPLUS}" = "true" ] || [ "${USE_KRITA}" = "true" ]; then \
git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git && \
cd ComfyUI_IPAdapter_plus && git checkout main && cd ..; \
fi; \
if [ "${USE_INPAINT}" = "true" ] || [ "${USE_KRITA}" = "true" ]; then \
git clone https://github.com/Acly/comfyui-inpaint-nodes.git && \
cd comfyui-inpaint-nodes && git checkout main && \
pip --cache-dir=${CACHE}/pip install opencv-python && cd ..; \
fi; \
if [ "${USE_TOOLING}" = "true" ] || [ "${USE_KRITA}" = "true" ]; then \
git clone https://github.com/Acly/comfyui-tooling-nodes.git && \
cd comfyui-tooling-nodes && git checkout main && cd ..; \
fi
WORKDIR ${ROOT}
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
COPY --chown=${USE_UID}:${USE_GID} . /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"]
feat: Enhance ComfyUI Dockerfile with additional features and configurations This commit significantly enhances the `Dockerfile` for the ComfyUI service by introducing several new features and configurations. Here's a detailed breakdown of the changes: 1. **Base Image Update**: - Updated the base image from `pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime` to `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime`. This ensures compatibility with newer versions of PyTorch and CUDA, providing better performance and support for recent hardware. 2. **Environment Variables**: - Introduced several new environment variables (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) to allow customization of the user and group IDs within the container. - Added flags (`USE_EDGE`, `USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`) to enable or disable optional features and integrations. 3. **User/Group Management**: - Added logic to create a user and group with specified IDs (`USE_UID` and `USE_GID`). This is useful for running the container in environments where specific user permissions are required. - Set default values for these variables, ensuring that the Dockerfile remains functional without explicit configuration. 4. **Optional Feature Integration**: - Included conditional logic to clone and install additional repositories based on the flags set (`USE_GGUF`, `USE_XFLUX`, `USE_CNAUX`, `USE_KRITA`, `USE_IPAPLUS`, `USE_INPAINT`, `USE_TOOLING`). This allows users to customize their ComfyUI installation by enabling only the features they need. - Ensured that dependencies for these optional features are installed correctly, including handling specific cases like separating ONNX Runtime installations to restore CUDA support. 5. **Python Version Update**: - Changed the Python command from `python` to `python3` in the CMD instruction to explicitly specify the use of Python 3, which is a best practice for clarity and compatibility. 6. **File Permissions and Ownership**: - Used `--chown=${USE_UID}:${USE_GID}` when copying files into the container to ensure that the correct user owns these files, preventing permission issues during execution. 7. **General Improvements**: - Improved readability and maintainability of the Dockerfile by organizing the steps logically and adding comments where necessary. - Ensured that all commands are idempotent, meaning they can be run multiple times without causing unintended side effects. - `USE_UID`: Specifies the user ID for the non-root user within the container. Default is set to value 0. - `USE_GID`: Specifies the group ID for the non-root user within the container. Default is set to value like 0. - `USE_USER`: Specifies the username for the non-root user within the container. Default is set to `root`. - `USE_GROUP`: Specifies the group name for the non-root user within the container. Default is set to `root`. - `USE_EDGE`: If set to `true`, clones and installs the latest development version of ComfyUI from the main branch. - `USE_GGUF`: If set to `true`, clones and installs the ComfyUI-GGUF extension for GPU acceleration. - `USE_XFLUX`: If set to `true`, clones and installs the x-flux-comfyui extension for additional functionalities. - `USE_CNAUX`: If set to `true`, clones and installs the comfyui_controlnet_aux extension for control net auxiliary features. - `USE_KRITA`: If set to `true`, clones and installs multiple extensions (comfyui_controlnet_aux, ComfyUI_IPAdapter_plus, comfyui-inpaint-nodes, comfyui-tooling-nodes) that are useful when integrating with Krita. - `USE_IPAPLUS`: If set to `true`, clones and installs the ComfyUI_IPAdapter_plus extension for IP Adapter functionalities. - `USE_INPAINT`: If set to `true`, clones and installs the comfyui-inpaint-nodes extension for inpainting capabilities. - `USE_TOOLING`: If set to `true`, clones and installs the comfyui-tooling-nodes extension for additional tooling features. These ARGs provide flexibility in configuring the Docker container, allowing users to tailor the ComfyUI installation to their specific needs.
2024-11-24 18:29:16 -07:00
CMD python3 -u main.py --listen --port 7860 ${CLI_ARGS}