|
| 1 | +# Customization |
| 2 | + |
| 3 | +This guide covers methods for adding your own models, custom nodes, and static input files into a custom `worker-comfyui`. |
| 4 | + |
| 5 | +There are two primary methods for customizing your setup: |
| 6 | + |
| 7 | +1. **Custom Dockerfile (recommended):** Create your own `Dockerfile` starting `FROM` one of the official `worker-comfyui` base images. This allows you to bake specific custom nodes, models, and input files directly into your image using `comfy-cli` commands. **This method does not require forking the `worker-comfyui` repository.** |
| 8 | +2. **Network Volume:** Store models on a persistent network volume attached to your RunPod endpoint. This is useful if you frequently change models or have very large models you don't want to include in the image build process. |
| 9 | + |
| 10 | +## Method 1: Custom Dockerfile |
| 11 | + |
| 12 | +This is the most flexible and recommended approach for creating reproducible, customized worker environments. |
| 13 | + |
| 14 | +1. **Create a `Dockerfile`:** In your own project directory, create a file named `Dockerfile`. |
| 15 | +2. **Start with a Base Image:** Begin your `Dockerfile` by referencing one of the official base images. Using the `-base` tag is recommended as it provides a clean ComfyUI install with necessary tools like `comfy-cli` but without pre-packaged models. |
| 16 | + ```Dockerfile |
| 17 | + # Start from a clean base image (replace <version> with the desired release) |
| 18 | + FROM runpod/worker-comfyui:<version>-base |
| 19 | + ``` |
| 20 | +3. **Install Custom Nodes:** Use the `comfy node install` command to add custom nodes by their repository name or URL. You can list multiple nodes. |
| 21 | + ```Dockerfile |
| 22 | + # Install desired custom nodes using comfy-cli |
| 23 | + RUN comfy node install comfyui-kjnodes comfyui-ic-light comfyui_ipadapter_plus comfyui_essentials ComfyUI-Hangover-Nodes |
| 24 | + ``` |
| 25 | +4. **Download Models:** Use the `comfy model download` command to fetch models and place them in the correct ComfyUI directories. |
| 26 | + ```Dockerfile |
| 27 | + # Download models using comfy-cli |
| 28 | + # Checkpoints |
| 29 | + RUN comfy model download --url https://huggingface.co/KamCastle/jugg/resolve/main/juggernaut_reborn.safetensors --relative-path models/checkpoints --filename juggernaut_reborn.safetensors |
| 30 | + # IPAdapter |
| 31 | + RUN comfy model download --url https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-plus_sd15.bin --relative-path models/ipadapter --filename ip-adapter-plus_sd15.bin |
| 32 | + # CLIP Vision |
| 33 | + RUN comfy model download --url https://huggingface.co/shiertier/clip_vision/resolve/main/SD15/model.safetensors --relative-path models/clip_vision --filename models.safetensors |
| 34 | + # Other Diffusion Models (e.g., IC-Light) |
| 35 | + RUN comfy model download --url https://huggingface.co/lllyasviel/ic-light/resolve/main/iclight_sd15_fcon.safetensors --relative-path models/diffusion_models --filename iclight_sd15_fcon.safetensors |
| 36 | + ``` |
| 37 | + - Ensure you use the correct `--relative-path` corresponding to ComfyUI's model directory structure (e.g., `models/checkpoints`, `models/loras`, `models/ipadapter`, `models/clip_vision`, etc.). |
| 38 | +5. **Add Static Input Files (Optional):** If your workflows consistently require specific input images, masks, videos, etc., you can copy them directly into the image. |
| 39 | + - Create an `input/` directory in the same folder as your `Dockerfile`. |
| 40 | + - Place your static files inside this `input/` directory. |
| 41 | + - Add a `COPY` command to your `Dockerfile`: |
| 42 | + ```Dockerfile |
| 43 | + # Copy local static input files into the ComfyUI input directory |
| 44 | + COPY input/ /comfyui/input/ |
| 45 | + ``` |
| 46 | + These files can then be referenced in your workflow using a "Load Image" (or similar) node pointing to the filename (e.g., `my_static_image.png`). |
| 47 | +
|
| 48 | +Once you have created your custom `Dockerfile`, refer to the [Deployment Guide](deployment.md#deploying-custom-setups) for instructions on how to build, push and deploy your custom image to RunPod. |
| 49 | +
|
| 50 | +### Complete Custom `Dockerfile` |
| 51 | +
|
| 52 | +```Dockerfile |
| 53 | +# Start from a clean base image (replace <version> with the desired release) |
| 54 | +FROM runpod/worker-comfyui:5.0.0-base |
| 55 | +
|
| 56 | +# Install desired custom nodes using comfy-cli |
| 57 | +RUN comfy node install comfyui-kjnodes comfyui-ic-light comfyui_ipadapter_plus comfyui_essentials ComfyUI-Hangover-Nodes |
| 58 | +
|
| 59 | +# Download models using comfy-cli |
| 60 | +# Checkpoints |
| 61 | +RUN comfy model download --url https://huggingface.co/KamCastle/jugg/resolve/main/juggernaut_reborn.safetensors --relative-path models/checkpoints --filename juggernaut_reborn.safetensors |
| 62 | +# IPAdapter |
| 63 | +RUN comfy model download --url https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-plus_sd15.bin --relative-path models/ipadapter --filename ip-adapter-plus_sd15.bin |
| 64 | +# CLIP Vision |
| 65 | +RUN comfy model download --url https://huggingface.co/shiertier/clip_vision/resolve/main/SD15/model.safetensors --relative-path models/clip_vision --filename models.safetensors |
| 66 | +# Other Diffusion Models (e.g., IC-Light) |
| 67 | +RUN comfy model download --url https://huggingface.co/lllyasviel/ic-light/resolve/main/iclight_sd15_fcon.safetensors --relative-path models/diffusion_models --filename iclight_sd15_fcon.safetensors |
| 68 | +
|
| 69 | +# Copy local static input files into the ComfyUI input directory (optional) |
| 70 | +# Assumes you have an 'input' folder next to your Dockerfile |
| 71 | +COPY input/ /comfyui/input/ |
| 72 | +``` |
| 73 | +
|
| 74 | +## Method 2: Network Volume |
| 75 | +
|
| 76 | +Using a Network Volume is primarily useful if you want to manage **models** separately from your worker image, especially if they are large or change often. |
| 77 | +
|
| 78 | +1. **Create a Network Volume**: |
| 79 | + - Follow the [RunPod Network Volumes guide](https://docs.runpod.io/pods/storage/create-network-volumes) to create a volume in the same region as your endpoint. |
| 80 | +2. **Populate the Volume with Models**: |
| 81 | + - Use one of the methods described in the RunPod guide (e.g., temporary Pod + `wget`, direct upload) to place your model files into the correct ComfyUI directory structure **within the volume**. The root of the volume corresponds to `/workspace` inside the container. |
| 82 | + ```bash |
| 83 | + # Example structure inside the Network Volume: |
| 84 | + # /models/checkpoints/your_model.safetensors |
| 85 | + # /models/loras/your_lora.pt |
| 86 | + # /models/vae/your_vae.safetensors |
| 87 | + ``` |
| 88 | + - **Important:** Ensure models are placed in the correct subdirectories (e.g., checkpoints in `models/checkpoints`, LoRAs in `models/loras`). |
| 89 | +3. **Configure Your Endpoint**: |
| 90 | + - Use the Network Volume in your endpoint configuration: |
| 91 | + - Either create a new endpoint or update an existing one (see [Deployment Guide](deployment.md)). |
| 92 | + - In the endpoint configuration, under `Advanced > Select Network Volume`, select your Network Volume. |
| 93 | +
|
| 94 | +**Note:** |
| 95 | +
|
| 96 | +- When a Network Volume is correctly attached, ComfyUI running inside the worker container will automatically detect and load models from the standard directories (`/workspace/models/...`) within that volume. |
| 97 | +- This method is **not suitable for installing custom nodes**; use the Custom Dockerfile method for that. |
0 commit comments