FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 # Environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ DEBIAN_FRONTEND=noninteractive # System dependencies RUN apt-get update && apt-get install -y \ python3.10 python3-pip git wget curl \ libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 ffmpeg \ git-lfs \ && rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # Initialize Git LFS RUN git lfs install # Clone ComfyUI core with shallow clone RUN git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git # Clone custom nodes with shallow cloning to reduce download size and avoid rate limits RUN git clone --depth 1 https://github.com/cubiq/ComfyUI_IPAdapter_plus.git /app/ComfyUI/custom_nodes/IPAdapter_plus || echo "Failed to clone IPAdapter_plus but continuing" && \ git clone --depth 1 https://github.com/Kosinkadink/ComfyUI-KJNodes.git /app/ComfyUI/custom_nodes/KJNodes || echo "Failed to clone KJNodes but continuing" && \ git clone --depth 1 https://github.com/SSitu/ComfyUI_UltimateSDUpscale.git /app/ComfyUI/custom_nodes/UltimateSDUpscale || echo "Failed to clone UltimateSDUpscale but continuing" && \ git clone --depth 1 https://github.com/ltdrdata/PuLID_ComfyUI.git /app/ComfyUI/custom_nodes/PuLID || echo "Failed to clone PuLID but continuing" && \ git clone --depth 1 https://github.com/cg196/ComfyUI-UseEverywhere.git /app/ComfyUI/custom_nodes/UseEverywhere || echo "Failed to clone UseEverywhere but continuing" && \ git clone --depth 1 https://github.com/melMass/comfy-mtb.git /app/ComfyUI/custom_nodes/mtb || echo "Failed to clone mtb but continuing" && \ git clone --depth 1 https://github.com/LucianoCirino/ComfyUI_Masquerade.git /app/ComfyUI/custom_nodes/Masquerade || echo "Failed to clone Masquerade but continuing" && \ git clone --depth 1 https://github.com/Fannovel16/comfyui-save-image-with-geninfo.git /app/ComfyUI/custom_nodes/SaveGenInfo || echo "Failed to clone SaveGenInfo but continuing" && \ git clone --depth 1 https://github.com/jamesWalker55/comfyui-various.git /app/ComfyUI/custom_nodes/Various || echo "Failed to clone Various but continuing" # Create necessary directories RUN mkdir -p /app/ComfyUI/models/checkpoints \ /app/ComfyUI/models/controlnet \ /app/ComfyUI/models/ipadapter \ /app/ComfyUI/models/pulid \ /app/ComfyUI/models/clip_vision \ /app/ComfyUI/input \ /app/ComfyUI/output \ /app/workflows \ /tmp/comfyui_user # Set permissions for directories that need write access RUN chmod -R 777 /app/ComfyUI/output \ /tmp/comfyui_user # Copy all required application files COPY requirements.txt . COPY app.py . COPY start.sh . COPY download_models.py . # Try to copy workflow files - if these fail, they'll be downloaded by start.sh COPY workflows/ /app/workflows/ # Instead of trying to copy LFS files in the Dockerfile, we'll let start.sh handle downloading them # This ensures we always get the complete files rather than LFS pointers # Make scripts executable RUN chmod +x /app/start.sh # Install Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Run model download script RUN python3 download_models.py || true # Expose ports for Gradio and ComfyUI EXPOSE 7860 8188 # Set the entrypoint ENTRYPOINT ["/app/start.sh"]