From 9e40f6af286992b8e1111bb3c3040707a15aae67 Mon Sep 17 00:00:00 2001 From: Kaouthia Date: Sat, 31 May 2025 01:32:01 +0100 Subject: [PATCH] Initial Commit --- Dockerfile | 56 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 31 +++++++++++++++++++++++++ entrypoint.sh | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc4c969 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,56 @@ +# ComfyUI Docker Build File by John Aldred +# http://www.johnaldred.com +# http://github.com/kaouthia + +# Use a minimal Python base image (adjust version as needed) +FROM python:3.12-slim + +# Allow passing in your host UID/GID (defaults 1000:1000) +ARG UID=1000 +ARG GID=1000 + +# Install OS deps and create the non-root user +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && groupadd --gid ${GID} appuser \ + && useradd --uid ${UID} --gid ${GID} --create-home --shell /bin/bash appuser \ + && rm -rf /var/lib/apt/lists/* + +# Install Mesa/GL and GLib so OpenCV can load libGL.so.1 for ComfyUI-VideoHelperSuite +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libgl1-mesa-glx \ + libglib2.0-0 \ + && rm -rf /var/lib/apt/lists/* + +# Copy and enable the startup script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Switch to non-root user +USER $UID:$GID + +# make ~/.local/bin available on the PATH so scripts like tqdm, torchrun, etc. are found +ENV PATH=/home/appuser/.local/bin:$PATH + +# Set the working directory +WORKDIR /app + +# Clone the ComfyUI repository (replace URL with the official repo) +RUN git clone https://github.com/comfyanonymous/ComfyUI.git + +# Change directory to the ComfyUI folder +WORKDIR /app/ComfyUI + +# Install ComfyUI dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# (Optional) Clean up pip cache to reduce image size +RUN pip cache purge + +# Expose the port that ComfyUI will use (change if needed) +EXPOSE 8188 + +# Run entrypoint first, then start ComfyUI +ENTRYPOINT ["/entrypoint.sh"] +CMD ["python","/app/ComfyUI/main.py","--listen","0.0.0.0"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d5db2af --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +# ComfyUI Docker Compose File by John Aldred +# http://www.johnaldred.com +# http://github.com/kaouthia + +services: + comfyk: + build: + dockerfile: Dockerfile + image: comfyui:latest + container_name: comfyui + ports: + - "8188:8188" + volumes: + # persist your models, output, and settings: + - c:/home/user/comfyui/models:/app/ComfyUI/models + + # persist your output images: + - c:/home/user/comfyui/output:/app/ComfyUI/output + + # persist all your settings & extra nodes: + - c:/home/user/comfyui/settings:/app/ComfyUI/user/default:rw + + # persist just your saved flows (overrides the workflows/ in default): + - c:/home/user/comfyui/flows:/app/ComfyUI/user/default/workflows:rw + + runtime: nvidia + environment: + - NVIDIA_VISIBLE_DEVICES=all + stdin_open: true + tty: true + restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..50d664e --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# ComfyUI Docker Startup File by John Aldred +# http://www.johnaldred.com +# http://github.com/kaouthia + +set -e + +CN_DIR=/app/ComfyUI/custom_nodes +declare -A REPOS=( + ["ComfyUI-Manager"]="https://github.com/ltdrdata/ComfyUI-Manager.git" + ["ComfyUI_essentials"]="https://github.com/cubiq/ComfyUI_essentials.git" + ["ComfyUI-Crystools"]="https://github.com/crystian/ComfyUI-Crystools.git" + ["rgthree-comfy"]="https://github.com/rgthree/rgthree-comfy.git" + ["ComfyUI-KJNodes"]="https://github.com/kijai/ComfyUI-KJNodes.git" + ["ComfyUI_UltimateSDUpscale"]="https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git" +) + +echo "↳ Syncing custom_nodes…" +mkdir -p "$CN_DIR" +for name in "${!REPOS[@]}"; do + url="${REPOS[$name]}" + target="$CN_DIR/$name" + + if [ -d "$target" ]; then + echo " ↳ $name already exists, skipping clone" + else + echo " ↳ Cloning $name" + git clone --depth 1 "$url" "$target" + fi +done + +echo "↳ Installing/upgrading dependencies…" +for dir in "$CN_DIR"/*/; do + req="$dir/requirements.txt" + if [ -f "$req" ]; then + echo " ↳ pip install --upgrade -r $req" + pip install --no-cache-dir --upgrade -r "$req" + fi +done + +echo "↳ Launching ComfyUI" +exec "$@"