From 89fe38b79fdf2c872f38627d82e8c2f5bb21c263 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Tue, 12 Aug 2025 19:32:28 -0400 Subject: [PATCH 01/16] Add local Docker support --- .dockerignore | 31 +++++++++++++++++ .gitignore | 1 + Dockerfile | 84 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 42 +++++++++++++++++++++++ entrypoint.sh | 76 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..ca3feff67a5f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +# This file should remain in sync with .gitignore. If you need to make changes, +# please add a comment explaining why. For items that must be removed, comment +# them out instead of deleting them. +__pycache__/ +*.py[cod] +/output/ +/input/ +# This file prevents the image from building and would be overwritten by the +# /data volume in any case. +#!/input/example.png +/models/ +/temp/ +/custom_nodes/ +!custom_nodes/example_node.py.example +extra_model_paths.yaml +/.vs +.vscode/ +.idea/ +venv/ +.venv/ +/web/extensions/* +!/web/extensions/logging.js.example +!/web/extensions/core/ +/tests-ui/data/object_info.json +/user/ +*.log +web_custom_versions/ +.DS_Store +openapi.yaml +filtered-openapi.yaml +uv.lock diff --git a/.gitignore b/.gitignore index 4e8cea71e551..847bfe03a0ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# If you modify this file, remember to update .dockerignore as well. __pycache__/ *.py[cod] /output/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..99d7cc70b886 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,84 @@ +# Docker buildfile for the ComfyUI image, with support for hardware +# acceleration, file ownership synchronization, custom nodes, and custom node +# managers. +# +# Authors: +# B. Bergeron +# + +# Use the recommended Python version 3.12, as specified in the README. +FROM python:3.12.11-bookworm AS comfyui-base + +# Install cmake, which is an indirect installation dependencies +RUN apt update \ + && apt install -y --no-install-recommends cmake \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* + +# Create a mount point for user-generated data. +RUN mkdir -p \ + /data/input \ + /data/output \ + /data/temp \ + /data/user + +# Create a regular user whose UID and GID will match the host user's at runtime. +# Also create a home directory for this user (-m), as some common Python tools +# (such as uv) interact with the user’s home directory. +RUN useradd -m comfyui +USER comfyui + +# Install ComfyUI under /comfyui. +WORKDIR /comfyui + +# Set up a Python virtual environment and configure it as the default Python. +# +# Reasons for using a virtual environment: +# - Some custom nodes use third-party tools like uv, which do not support +# user-level installations. +# - Custom node managers may install or update dependencies as the regular user, +# so a global installation is not an option. +# This leaves virtual environments as the only viable choice. +RUN python -m venv .venv +ENV PATH="/comfyui/.venv/bin:$PATH" + +# Install Python dependencies. This step is also performed automatically by the +# entrypoint script, but doing it at build time reduces startup time on the +# first run. +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Install ComfyUI and link the data mount points. +COPY . . +RUN ln -sf /data/* . + +# Purely declarative: inform Docker and image users that this image is designed +# to listen on port 8188 for the web GUI. +EXPOSE 8188 + +# Declare persistent volumes: +# - /data: stores user-generated data from ComfyUI, +# - /comfyui/.venv: stores Python data generated by the entrypoint and custom +# node managers, +# - /comfyui/custom_nodes: stores custom nodes installed at runtime by custom +# node managers, +# - /home/comfyui: stores data from Python packages that may write outside the +# virtual environment and into the user’s home directory. +VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/home/comfyui" ] + +# Switch back to root to run the entrypoint and ensure it is executable. +USER root +RUN chmod +x entrypoint.sh +ENTRYPOINT [ "./entrypoint.sh" ] +CMD [ "python", "./main.py" ] + +# Known issue: Some custom nodes require additional system dependencies, which +# are not as easy to install as Python dependencies. If this is the case, you +# can use the instruction below to install the required packages. +#RUN apt update \ +# && apt install -y --no-install-recommends \ +# package-1 \ +# package-2 \ +# ... \ +# && apt clean \ +# && rm -rf /var/lib/apt/lists/* diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000000..c6bf30456160 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +# Docker Compose file to run ComfyUI locally using Docker. +# +# Authors: +# B. Bergeron +# + +services: + comfyui: + container_name: comfyui + build: . + + ports: + - 127.0.0.1:8188:8188 + + # Optional: enable GPU access for hardware acceleration. + deploy: + resources: + reservations: + devices: + - capabilities: [gpu] + volumes: + # Share custom nodes and models with the container. + - ./custom_nodes:/comfyui/custom_nodes + - ./models:/comfyui/models + # Optional: mount the user data directory. + #- data:/data/ + + environment: + # Overwrite the container user's UID and GID to match the host's. This + # allows files created by ComfyUI to be mounted on the host without + # permission issues. + UID: 1000 + GID: 1000 + # Declare additional Python packages to install. Useful when a custom node + # pack does not properly specify all its dependencies or relies on + # optional dependencies. + #PIP_EXTRA_PACKAGES: + + # Optional: Override the default command. In this case, configure ComfyUI to + # listen on all network interfaces (which is required when not using + # `network_mode=host`.) + command: python ./main.py --listen 0.0.0.0 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000000..9b844eb1d89e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +# Entrypoint script for the ComfyUI Docker image. +# +# Authors: +# B. Bergeron +# + +set -e + +user="comfyui" +user_group="$user" + +# Allow users to specify a UID and GID matching their own, so files created +# inside the container retain the same numeric ownership when mounted on the +# host. +if [ -n "$UID" ] && [ -n "$GID" ]; then + echo "[entrypoint] Setting user UID and GID..." + usermod -u "$UID" "$user" > /dev/null + groupmod -g "$GID" "$user_group" +else + echo "[entrypoint] Missing UID or GID environment variables; keeping default values." +fi + + +echo "[entrypoint] Changing directory ownership..." +chown -R "$user:$user_group" /data /comfyui/custom_nodes /comfyui/.venv /home/comfyui + +# Add the user to the groups owning /dev/nvidia* devices to ensure CUDA access. +# Typically, these devices belong to a single "video" group, but to be safe, we +# add the user to each device's group individually. +echo "[entrypoint] Adding user to GPU device groups..." +for dev in /dev/nvidia*; do + # Known issue: There is no universal standard for group IDs across Linux + # systems, so this may add the user to unexpected groups. For example, the + # 'video' group on some systems uses GID 27, which corresponds to 'sudo' in + # the python:3.12 image. This should not cause serious problems. + group=$(ls -ld "$dev" | awk '{print $4}') + usermod -aG "$group" "$user" +done + + +# Install packages listed in ./requirements.txt, requirement files under +# ./custom_nodes, and any specified in PIP_EXTRA_PACKAGES. Also store a hash of +# all dependencies to detect when new or updated packages need to be installed. +packages_hash_file="/home/comfyui/pkghash" + +packages_comfyui=$(cat requirements.txt) +packages_custom=$(find custom_nodes -name requirements.txt -exec cat {} \;) +packages_extras=$(echo "$PIP_EXTRA_PACKAGES" | tr ' ' '\n') + +current_hash=$( + { + echo "$packages_comfyui"; + echo "$packages_custom"; + echo "$packages_extras" + } | sort | sha256sum | awk '{print $1}' +) + +if [ ! -f "$packages_hash_file" ] || [ "$current_hash" != "$(cat $packages_hash_file)" ]; then + echo "[entrypoint] Installing new python dependencies..." + reqs="-r requirements.txt" + for req in custom_nodes/*/requirements.txt; do + [ -f "$req" ] && reqs="$reqs -r $req" + done + + su -c "pip install -q --disable-pip-version-check --no-cache-dir $reqs $PIP_EXTRA_PACKAGES" comfyui + echo "$current_hash" > "$packages_hash_file" +else + echo "[entrypoint] Requirements unchanged, skipping install" +fi + + +# Run command as comfyui +echo "[entrypoint] Running command" +exec su -c "$*" comfyui From 0f734f857008244e6cc3cca88a3a901ce0f6e93f Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Wed, 13 Aug 2025 10:36:35 -0400 Subject: [PATCH 02/16] Add instructions for Docker installation --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 91fb510e194d..1cfe29d011a1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ ComfyUI lets you design and execute advanced stable diffusion pipelines using a - Get the latest commits and completely portable. - Available on Windows. +#### [Docker Install](#running-with-docker) +- Run ComfyUI inside an isolated Docker container +- Most secure way to run ComfyUI and custom node packs +- Requires Docker and Docker Compose +- Supports NVIDIA GPUs (Not tested on other hardware.) + #### [Manual Install](#manual-install-windows-linux) Supports all operating systems and GPU types (NVIDIA, AMD, Intel, Apple Silicon, Ascend). @@ -319,6 +325,25 @@ For models compatible with Iluvatar Extension for PyTorch. Here's a step-by-step 1. Install the Iluvatar Corex Toolkit by adhering to the platform-specific instructions on the [Installation](https://support.iluvatar.com/#/DocumentCentre?id=1&nameCenter=2&productId=520117912052801536) 2. Launch ComfyUI by running `python main.py` +## Running with Docker + +Start by installing Docker and Docker Compose on your host. Next, edit +`docker-compose.yaml` and update the `UID` and `GID` variables to match your +user. Additional fields are documented in the file for further customization. + +Once ready, build and run the image locally: + +``` +docker compose build +docker compose up +``` + +To stop and remove the container along with its volumes, run: + +``` +docker compose down -v +``` + # Running ```python main.py``` From 144c9047b69b1dc37256b338dd6992b3468ad819 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Wed, 13 Aug 2025 11:14:54 -0400 Subject: [PATCH 03/16] Persist models installed by model managers --- Dockerfile | 3 ++- entrypoint.sh | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99d7cc70b886..bbde988aeb66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,9 +62,10 @@ EXPOSE 8188 # node managers, # - /comfyui/custom_nodes: stores custom nodes installed at runtime by custom # node managers, +# - /comfyui/models: Stores models installed by model managers, # - /home/comfyui: stores data from Python packages that may write outside the # virtual environment and into the user’s home directory. -VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/home/comfyui" ] +VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/comfyui/models", "/home/comfyui" ] # Switch back to root to run the entrypoint and ensure it is executable. USER root diff --git a/entrypoint.sh b/entrypoint.sh index 9b844eb1d89e..cbaec72f93de 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,7 +24,12 @@ fi echo "[entrypoint] Changing directory ownership..." -chown -R "$user:$user_group" /data /comfyui/custom_nodes /comfyui/.venv /home/comfyui +chown -R "$user:$user_group" \ + /data \ + /comfyui/custom_nodes \ + /comfyui/models \ + /comfyui/.venv \ + /home/comfyui # Add the user to the groups owning /dev/nvidia* devices to ensure CUDA access. # Typically, these devices belong to a single "video" group, but to be safe, we From f2ea706b341757bbd1ac9bb63d774161361b98d5 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Wed, 13 Aug 2025 11:28:57 -0400 Subject: [PATCH 04/16] Install extra system dependencies at build-time --- Dockerfile | 28 ++++++++++++---------------- docker-compose.yml | 8 ++++++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index bbde988aeb66..950b4eb06e40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,11 +9,10 @@ # Use the recommended Python version 3.12, as specified in the README. FROM python:3.12.11-bookworm AS comfyui-base +ARG APT_EXTRA_PACKAGES + # Install cmake, which is an indirect installation dependencies -RUN apt update \ - && apt install -y --no-install-recommends cmake \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* +RUN apt update && apt install -y --no-install-recommends cmake # Create a mount point for user-generated data. RUN mkdir -p \ @@ -67,19 +66,16 @@ EXPOSE 8188 # virtual environment and into the user’s home directory. VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/comfyui/models", "/home/comfyui" ] -# Switch back to root to run the entrypoint and ensure it is executable. +# Switch back to root to run the entrypoint and to install additional system +# dependencies USER root + +# Install additional system dependencies +RUN apt install -y --no-install-recommends $APT_EXTRA_PACKAGES \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* + +# Configure entrypoint RUN chmod +x entrypoint.sh ENTRYPOINT [ "./entrypoint.sh" ] CMD [ "python", "./main.py" ] - -# Known issue: Some custom nodes require additional system dependencies, which -# are not as easy to install as Python dependencies. If this is the case, you -# can use the instruction below to install the required packages. -#RUN apt update \ -# && apt install -y --no-install-recommends \ -# package-1 \ -# package-2 \ -# ... \ -# && apt clean \ -# && rm -rf /var/lib/apt/lists/* diff --git a/docker-compose.yml b/docker-compose.yml index c6bf30456160..8e4ff0e67359 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,11 @@ services: comfyui: container_name: comfyui - build: . + build: + context: . + args: + # Declare additional system dependencies for custom nodes + APT_EXTRA_PACKAGES: ports: - 127.0.0.1:8188:8188 @@ -34,7 +38,7 @@ services: # Declare additional Python packages to install. Useful when a custom node # pack does not properly specify all its dependencies or relies on # optional dependencies. - #PIP_EXTRA_PACKAGES: + PIP_EXTRA_PACKAGES: # Optional: Override the default command. In this case, configure ComfyUI to # listen on all network interfaces (which is required when not using From 80519fd53bc9dc5d3c6ab191a3dc491deb7a5765 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Wed, 13 Aug 2025 11:31:33 -0400 Subject: [PATCH 05/16] Inform user that installation might take a while --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index cbaec72f93de..d59369cf7ef2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -63,7 +63,7 @@ current_hash=$( ) if [ ! -f "$packages_hash_file" ] || [ "$current_hash" != "$(cat $packages_hash_file)" ]; then - echo "[entrypoint] Installing new python dependencies..." + echo "[entrypoint] Installing new python dependencies, this might take a while..." reqs="-r requirements.txt" for req in custom_nodes/*/requirements.txt; do [ -f "$req" ] && reqs="$reqs -r $req" From cc524b7c862122e5c98b8c27090396bba6531049 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Wed, 13 Aug 2025 12:03:27 -0400 Subject: [PATCH 06/16] Update ownership of /comfyui to comfyui user --- entrypoint.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index d59369cf7ef2..7f86613487b6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,9 +26,7 @@ fi echo "[entrypoint] Changing directory ownership..." chown -R "$user:$user_group" \ /data \ - /comfyui/custom_nodes \ - /comfyui/models \ - /comfyui/.venv \ + /comfyui \ /home/comfyui # Add the user to the groups owning /dev/nvidia* devices to ensure CUDA access. From bee3c099b9be6096942bc7b5d8025907b2bcb8c6 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Thu, 14 Aug 2025 11:17:49 -0400 Subject: [PATCH 07/16] Force LF eol for entrypoint.sh --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 5b3c15bb47c2..c68ee9205cb2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,6 @@ /web/assets/** linguist-generated /web/** linguist-vendored comfy_api_nodes/apis/__init__.py linguist-generated +# Force LF eol for Docker entrypoint (fix "exec: no such file or directory" +# error with CRLF checkouts) +entrypoint.sh text eol=lf From e68b3b0d0eb11b1349b8e6b9c9a03e807594f816 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Tue, 19 Aug 2025 17:44:41 -0400 Subject: [PATCH 08/16] Remove superfluous command-separators --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7f86613487b6..df1e275d04da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -54,8 +54,8 @@ packages_extras=$(echo "$PIP_EXTRA_PACKAGES" | tr ' ' '\n') current_hash=$( { - echo "$packages_comfyui"; - echo "$packages_custom"; + echo "$packages_comfyui" + echo "$packages_custom" echo "$packages_extras" } | sort | sha256sum | awk '{print $1}' ) From a3648d1a3f11a9b0f98308f12511dbbcce980a9e Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Tue, 19 Aug 2025 18:05:58 -0400 Subject: [PATCH 09/16] Add @bbergeron0 to CODEOWNER --- Dockerfile | 4 ---- docker-compose.yml | 4 ---- entrypoint.sh | 4 ---- 3 files changed, 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 950b4eb06e40..592b6a4fa031 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,6 @@ # Docker buildfile for the ComfyUI image, with support for hardware # acceleration, file ownership synchronization, custom nodes, and custom node # managers. -# -# Authors: -# B. Bergeron -# # Use the recommended Python version 3.12, as specified in the README. FROM python:3.12.11-bookworm AS comfyui-base diff --git a/docker-compose.yml b/docker-compose.yml index 8e4ff0e67359..f7263970ca27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,4 @@ # Docker Compose file to run ComfyUI locally using Docker. -# -# Authors: -# B. Bergeron -# services: comfyui: diff --git a/entrypoint.sh b/entrypoint.sh index df1e275d04da..f059293e8699 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,6 @@ #!/bin/sh # Entrypoint script for the ComfyUI Docker image. -# -# Authors: -# B. Bergeron -# set -e From 5a8f5ed69d339ffca389f640a262e261657e5581 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Sun, 24 Aug 2025 20:28:37 -0400 Subject: [PATCH 10/16] Use recommended compose file name for Docker Compose --- README.md | 2 +- docker-compose.yml => compose.yaml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docker-compose.yml => compose.yaml (100%) diff --git a/README.md b/README.md index 1cfe29d011a1..6cc3193489de 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,7 @@ For models compatible with Iluvatar Extension for PyTorch. Here's a step-by-step ## Running with Docker Start by installing Docker and Docker Compose on your host. Next, edit -`docker-compose.yaml` and update the `UID` and `GID` variables to match your +`compose.yaml` and update the `UID` and `GID` variables to match your user. Additional fields are documented in the file for further customization. Once ready, build and run the image locally: diff --git a/docker-compose.yml b/compose.yaml similarity index 100% rename from docker-compose.yml rename to compose.yaml From 901f76d794da6a227c1da93a2e6a4248e26133d8 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Mon, 25 Aug 2025 22:21:07 -0400 Subject: [PATCH 11/16] Use stable apt-get CLI interface instead of apt --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 592b6a4fa031..ce43bfbac162 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ FROM python:3.12.11-bookworm AS comfyui-base ARG APT_EXTRA_PACKAGES # Install cmake, which is an indirect installation dependencies -RUN apt update && apt install -y --no-install-recommends cmake +RUN apt-get update && apt-get install -y --no-install-recommends cmake # Create a mount point for user-generated data. RUN mkdir -p \ @@ -67,8 +67,8 @@ VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/comfyui/models", USER root # Install additional system dependencies -RUN apt install -y --no-install-recommends $APT_EXTRA_PACKAGES \ - && apt clean \ +RUN apt-get install -y --no-install-recommends $APT_EXTRA_PACKAGES \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Configure entrypoint From 4fff4dc0329e5678d6ccaa5b9cc6e69ec379884c Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Mon, 25 Aug 2025 22:56:35 -0400 Subject: [PATCH 12/16] Fix permission issue on legacy builds --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce43bfbac162..11e1f6e01609 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,10 +21,16 @@ RUN mkdir -p \ # Also create a home directory for this user (-m), as some common Python tools # (such as uv) interact with the user’s home directory. RUN useradd -m comfyui -USER comfyui -# Install ComfyUI under /comfyui. +# Install ComfyUI under /comfyui and set folder ownership to the comfyui user. +# With the legacy Docker builder (DOCKER_BUILDKIT=0), WORKDIR always creates missing +# directories as root (even if a different USER is active). To ensure the comfyui user +# can write inside, ownership must be fixed manually. WORKDIR /comfyui +RUN chown comfyui:comfyui . + +# Install ComfyUI as ComfyUI +USER comfyui # Set up a Python virtual environment and configure it as the default Python. # From ab4a2a575e3a49177e328884ec57ec7cac2d3566 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Mon, 25 Aug 2025 23:12:14 -0400 Subject: [PATCH 13/16] Don't rebuild whole image when APT_EXTRA_PACKAGES changes --- Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11e1f6e01609..e124ca428033 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,6 @@ # Use the recommended Python version 3.12, as specified in the README. FROM python:3.12.11-bookworm AS comfyui-base -ARG APT_EXTRA_PACKAGES - # Install cmake, which is an indirect installation dependencies RUN apt-get update && apt-get install -y --no-install-recommends cmake @@ -72,12 +70,13 @@ VOLUME [ "/data", "/comfyui/.venv", "/comfyui/custom_nodes", "/comfyui/models", # dependencies USER root -# Install additional system dependencies -RUN apt-get install -y --no-install-recommends $APT_EXTRA_PACKAGES \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - # Configure entrypoint RUN chmod +x entrypoint.sh ENTRYPOINT [ "./entrypoint.sh" ] CMD [ "python", "./main.py" ] + +# Install additional system dependencies +ARG APT_EXTRA_PACKAGES +RUN apt-get install -y --no-install-recommends $APT_EXTRA_PACKAGES \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* From 0f3071cd9221a9bea23b3f96a73f6ec8287b7a1b Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Tue, 9 Sep 2025 23:07:37 -0400 Subject: [PATCH 14/16] Improved documentation --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6cc3193489de..76e08f8a1dc6 100644 --- a/README.md +++ b/README.md @@ -327,20 +327,24 @@ For models compatible with Iluvatar Extension for PyTorch. Here's a step-by-step ## Running with Docker -Start by installing Docker and Docker Compose on your host. Next, edit -`compose.yaml` and update the `UID` and `GID` variables to match your -user. Additional fields are documented in the file for further customization. +Start by installing Docker, Docker Compose, and the NVIDIA Container Toolkit on +your host. Next, edit `compose.yaml` and update the `UID` and `GID` variables to +match your user. Additional fields are documented in the file for further +customization. Once ready, build and run the image locally: -``` +```shell +# (Re)build the Docker image. Run this before the first start, after updating +# ComfyUI, or after changing any build arguments in `compose.yaml`. docker compose build +# Start ComfyUI. This reuses the most recently built image. docker compose up ``` To stop and remove the container along with its volumes, run: -``` +```shell docker compose down -v ``` From 7f209b855fcc21a51fab16eadc62e1c15318b234 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Tue, 9 Sep 2025 23:35:24 -0400 Subject: [PATCH 15/16] Remove superfluous interface binding --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index f7263970ca27..52087f337ef6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -10,7 +10,7 @@ services: APT_EXTRA_PACKAGES: ports: - - 127.0.0.1:8188:8188 + - 8188:8188 # Optional: enable GPU access for hardware acceleration. deploy: From 32d2ece3fe1c52521f3533f4743b782c3e2bb284 Mon Sep 17 00:00:00 2001 From: "B. Bergeron" Date: Mon, 20 Oct 2025 20:09:47 -0400 Subject: [PATCH 16/16] Remove unused "AS" docker statement --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e124ca428033..6dd61a2bdf31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # managers. # Use the recommended Python version 3.12, as specified in the README. -FROM python:3.12.11-bookworm AS comfyui-base +FROM python:3.12.11-bookworm # Install cmake, which is an indirect installation dependencies RUN apt-get update && apt-get install -y --no-install-recommends cmake