/jmdots-comfyui

A simple container lifecycle management solution for ComfyUI using docker-compose.

Primary LanguageDockerfileOtherNOASSERTION

jmdots-comfyui

JMDOTS ComfyUI

A simple container lifecycle management solution for ComfyUI using docker-compose.

ComfyUI is a revolutionary node-based graphical user interface (GUI) designed to facilitate the use of Stable Diffusion, a powerful platform for generating AI-driven images. Unlike traditional text-based interfaces, ComfyUI uses a visual approach where users can create and manage complex workflows through interconnected nodes. This setup allows for greater flexibility, customization, and understanding of each step involved in the image generation process.

For more information, refer to the Beginner's Guide to ComfyUI and the Definitive Guide to ComfyUI.

Features

  • Support make managing the container lifecycle.
  • Provide a Dockerfile for NVIDIA GPUs based on the NVIDIA PyTorch image.
  • Support ComfyUI Manager first-install as well as existing installations already present in a host directory.
  • Support mounting a host directory containing models as a volume into the container.
    • Note: This models directory won't be the one used by ComfyUI Manager.
  • Provide a simple default extra_model_paths.yaml.
    • Note: This file will not address ComfyUI Manager's paths.
  • Support mounting a host directory to ComfyUI/custom_nodes as a volume into the container.
    • Note: This enables persistence for ComfyUI Manager.
  • Bind the container's port to the host's localhost for security.
  • Support Docker CE container manager.
  • Delegate to ComfyUI Manager all of the hard things like managing models, custom nodes, etc.
  • Reach the point of zero warnings seen on container boot.
  • Use .env to drive git-ignored configuration.

Roadmap

  • Implement GitHub Actions CI for building images that push to Docker Hub.
  • Provide a pre-built Docker image that supports NVIDIA GPUs.
  • Support running ComfyUI across multiple NVIDIA GPUs present on the host.
  • Support Podman container manager.
  • Support podman-compose managing the container lifecycle.
  • Support AMD GPUs.
  • Support Kubernetes managing the container lifecycle.

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/jmdots/jmdots-comfyui.git
    cd jmdots-comfyui
  2. Create a .env file or copy the example:

    cp .env.example .env
  3. Customize the .env file as needed:

    COMFYUI_IMAGE_NAME=jmdots/jmdots-comfyui
    COMFYUI_TAG=latest
    COMFYUI_CONTAINER_NAME=jmdots-comfyui
    COMFYUI_HOST_PORT=8188
    COMFYUI_CONTAINER_PORT=8188
    COMFYUI_VOLUME_MODELS=$(pwd)/var/ComfyUI/models
    COMFYUI_VOLUME_CUSTOM_NODES=$(pwd)/var/ComfyUI/custom_nodes
    COMFYUI_BIND_ADDRESS=127.0.0.1
    COMFYUI_MANAGER_REPO=https://github.com/ltdrdata/ComfyUI-Manager.git
    COMFYUI_CUSTOM_NODES_DIR=var/ComfyUI/custom_nodes/ComfyUI-Manager
  4. Build and start the Docker containers:

    make rebuild

Interfaces

make

  • make build: Build or rebuild container images
  • make up: Create and start enabled containers
  • make down: Stop and remove enabled containers, networks
  • make restart: Restart enabled containers
  • make rebuild: Rebuild container images and restart enabled containers
  • make stop: Stop services
  • make logs: Watch output from enabled containers
  • make nvidia: Watch NVIDIA GPU usage
  • make ps: List enabled containers
  • make rm: Remove stopped service containers
  • make shell: Get a shell prompt in the running container
  • make manager: Clone or update ComfyUI-Manager

Usage Examples

  • To check the logs of the running containers:

    make logs
  • To access a shell in the running container:

    make shell
  • To monitor NVIDIA GPU usage:

    make nvidia

Customizing Your Model Paths

(optional)

Note: This feature is not related to ComfyUI Manage.

The repository includes a default extra_model_paths.example.yaml file, which is copied into the container image as extra_model_paths.yaml. Since this file needs customization for different use cases, follow these steps to set up your own configuration:

  1. Copy the Example File:

    cp extra_model_paths.example.yaml extra_model_paths.yaml

    The extra_model_paths.yaml file is git-ignored to prevent it from being tracked by version control.

  2. Customize the File: Edit the extra_model_paths.yaml file according to your specific requirements.

  3. Mount the Customized File: To mount your customized extra_model_paths.yaml into the container, uncomment the line in docker-compose.yaml for mounting ./extra_models_paths.yaml and make restart.

Note: You may find the Docker Compose override file pattern helpful if you use this feature.

Deployment Contexts

This project has been successfully deployed and tested in the following contexts:

Operating System CPU GPU Memory
Ubuntu 22.04.4 LTS (amd64) AMD 7700X NVIDIA RTX 4090 (24GB) 128GB DDR5
Ubuntu 22.04.4 LTS (amd64) Intel i9-14900HX NVIDIA RTX 4090 (16GB) Mobile 64GB DDR5

Development

To contribute to this project, follow these steps:

  1. Fork the repository.
  2. Clone your fork:
    git clone https://github.com/<your-username>/jmdots-comfyui.git
    cd jmdots-comfyui
  3. Create a new branch for your feature or bugfix:
    git checkout -b my-feature-branch
  4. Make your changes and commit them:
    git commit -m "Description of my changes"
  5. Push your changes to your fork:
    git push origin my-feature-branch
  6. Open a pull request to the main repository.

Continuous Integration (CI)

Note: This feature is not yet active.

This project uses GitHub Actions for CI. The workflow is set up to build and push the Docker image to Docker Hub whenever a new tag is pushed.

Setting Up GitHub Secrets

To securely handle your Docker Hub credentials, add them as secrets in your GitHub repository settings:

  1. Go to your GitHub repository.
  2. Navigate to Settings > Secrets > New repository secret.
  3. Add two secrets:
    • DOCKER_USERNAME: Your Docker Hub username.
    • DOCKER_PASSWORD: Your Docker Hub password.

Contributing

Contributions are welcome! Please open an issue or submit a pull request with your improvements. Please ensure you understand the license sections below before contributing. Thank you!

License

This project includes components licensed under the GNU General Public License (GPL) version 3.0:

========================
jmdots-comfyui by JMDOTS
========================
Copyright © 2024 Joshua M. Dotson (contact@jmdots.com)

JMDOTS-DUAL-LICENSE-1.2
=======================
https://legal.jmdots.com/licenses/

Personal, Non-Commercial License
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This software is provided under the GNU Affero General Public License (AGPL)
version 3 or later. You are free to use, modify, and distribute this
software for personal, non-commercial use under the terms of the AGPL. If you
modify this software and distribute it, you must also make the modified
source code available under the same license terms. There is no warranty for
this software, to the extent permitted by applicable law.

For more details, please refer to the full text of the GNU AGPL: [GNU Affero
General Public License](http://www.gnu.org/licenses/)

Commercial License
~~~~~~~~~~~~~~~~~~
This software is available under a Commercial License for any business,
commercial, enterprise, or governmental use. The Commercial License allows
you to use, modify, and distribute this software in proprietary applications
without the requirement to disclose source code modifications or derivative
works. Under this license, you receive additional support and maintenance
services.

For information on purchasing a commercial license, please contact us at
[sales@jmdots.com](mailto:sales@jmdots.com) or visit our website at [JMDOTS
GitHub](http://www.github.com/jmdots/).

Limited Liability
~~~~~~~~~~~~~~~~~
In no event shall the authors or copyright holders be liable for any claim,
damages, or other liability arising from the use or distribution of this
software.