# syntax=docker/dockerfile:1 FROM python:3.10-slim ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PORT=7860 \ COMFYUI_PATH=/app/ComfyUI \ OMP_NUM_THREADS=2 \ MKL_NUM_THREADS=2 \ OPENBLAS_NUM_THREADS=2 \ NUMEXPR_NUM_THREADS=2 \ TOKENIZERS_PARALLELISM=false \ HF_XET_HIGH_PERFORMANCE=1 EXPOSE 7860 RUN apt-get update && apt-get install -y --no-install-recommends \ git \ git-lfs \ curl \ wget \ ca-certificates \ ffmpeg \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ libgomp1 \ build-essential \ && rm -rf /var/lib/apt/lists/* \ && git lfs install RUN useradd --create-home --shell /bin/bash --uid 1000 user WORKDIR /app RUN python -m pip install --upgrade pip setuptools wheel && \ python -m pip install \ "torch==2.7.1" \ "torchvision==0.22.1" \ "torchaudio==2.7.1" \ --index-url https://download.pytorch.org/whl/cpu RUN git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git /app/ComfyUI && \ cd /app/ComfyUI && \ python -m pip install -r requirements.txt # Keep the CPU PyTorch versions after installing ComfyUI requirements. RUN python -m pip install --force-reinstall \ "torch==2.7.1" \ "torchvision==0.22.1" \ "torchaudio==2.7.1" \ --index-url https://download.pytorch.org/whl/cpu # ------------------------------------------------------------------ # Seven custom nodes # ------------------------------------------------------------------ RUN mkdir -p /app/ComfyUI/custom_nodes && \ cd /app/ComfyUI/custom_nodes && \ git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager.git comfyui-manager && \ git clone --depth 1 https://github.com/RealRebelAI/ComfyUI-GGUF_KREA-2.git ComfyUI-GGUF_KREA-2 && \ git clone --depth 1 https://github.com/crystian/comfyui-crystools.git comfyui-crystools && \ git clone --depth 1 https://github.com/rgthree/rgthree-comfy.git rgthree-comfy && \ git clone --depth 1 https://github.com/kijai/ComfyUI-KJNodes.git ComfyUI-KJNodes && \ git clone --depth 1 https://github.com/nicolab28/ComfyUI-ClipProj.git ComfyUI-ClipProj && \ git clone --depth 1 https://github.com/ethanfel/ComfyUI-Krea2TextEncoder.git ComfyUI-Krea2TextEncoder && \ git clone --depth 1 https://github.com/KLL535/ComfyUI_SimpleButcher.git ComfyUI_SimpleButcher && \ git clone --depth 1 https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch.git ComfyUI-Inpaint-CropAndStitch && \ git clone --depth 1 https://github.com/LAOGOU-666/Comfyui-Memory_Cleanup.git Comfyui-Memory_Cleanup && \ git clone --depth 1 https://github.com/ssitu/ComfyUI_UltimateSDUpscale.git ComfyUI_UltimateSDUpscale && \ git clone --depth 1 https://github.com/ty0x2333/ComfyUI-Dev-Utils.git ComfyUI-Dev-Utils && \ git clone --depth 1 https://github.com/ServiceStack/comfy-asset-downloader.git comfy-asset-downloader && \ git clone --depth 1 https://github.com/traugdor/ComfyUI-UltimateSDUpscale-GGUF.git ComfyUI-UltimateSDUpscale-GGUF && \ git clone --depth 1 https://github.com/tori29umai0123/ComfyUI-Model_Downloader.git ComfyUI-Model_Downloader && \ git clone --depth 1 https://github.com/ciri/comfyui-model-downloader.git comfyui-model-downloader && \ git clone --depth 1 https://github.com/PanicTitan/ComfyUI-Gallery ComfyUI-Gallery && \ git clone --depth 1 https://github.com/christian-byrne/audio-separation-nodes-comfyui audio-separation-nodes-comfyui && \ git clone --depth 1 https://github.com/yolain/ComfyUI-Easy-Use ComfyUI-Easy-Use && \ git clone --depth 1 https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite ComfyUI-VideoHelperSuite && \ git clone --depth 1 https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside ComfyUI_RyanOnTheInside && \ git clone --depth 1 https://github.com/sou319b/comfyui-youtube-downloader comfyui-youtube-downloader RUN set -eux; \ find /app/ComfyUI/custom_nodes -maxdepth 2 -name "requirements.txt" -exec python -m pip install --no-cache-dir -r {} \; RUN python -m pip install \ "huggingface_hub>=0.33" \ "hf_transfer>=0.1.9" \ psutil \ websocket-client \ opencv-python-headless \ einops \ transformers \ safetensors \ color-matcher \ scikit-image \ numba \ dynamicprompts \ diffusers # ------------------------------------------------------------------ # Runtime directories. # # IMPORTANT: # ComfyUI 0.35.x creates /app/ComfyUI/user at startup. # It must be writable by the non-root "user" account. # ------------------------------------------------------------------ RUN mkdir -p \ /app/ComfyUI/user \ /app/ComfyUI/models/unet \ /app/ComfyUI/models/diffusion_models \ /app/ComfyUI/models/text_encoders \ /app/ComfyUI/models/clip \ /app/ComfyUI/models/vae \ /app/ComfyUI/models/loras \ /app/ComfyUI/models/upscale_models \ /app/ComfyUI/models/checkpoints \ /app/ComfyUI/workflows \ /app/ComfyUI/input \ /app/ComfyUI/output \ /app/ComfyUI/temp \ /data && \ chown -R user:user \ /app/ComfyUI/user \ /app/ComfyUI/models \ /app/ComfyUI/workflows \ /app/ComfyUI/input \ /app/ComfyUI/output \ /app/ComfyUI/temp \ /data COPY --chown=user start.sh /app/start.sh RUN chmod +x /app/start.sh && chown user:user /app/start.sh USER user WORKDIR /app/ComfyUI ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONPATH=/app/ComfyUI # Build-time sanity check. RUN python - <<'PY' import torch print("PyTorch:", torch.__version__) print("CUDA available:", torch.cuda.is_available()) assert torch.__version__.startswith("2.7.1") assert not torch.cuda.is_available() import comfy_kitchen print("comfy_kitchen:", comfy_kitchen.__file__) print("int8_attention_is_available:", hasattr(comfy_kitchen, "int8_attention_is_available")) PY COPY ./workflow /app/ComfyUI/user/default/workflows/ HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=5 \ CMD curl -fsS http://127.0.0.1:7860/system_stats >/dev/null || exit 1 ENTRYPOINT ["/app/start.sh"]