Skip to content

Commit 3588cdb

Browse files
committed
feat: refactor the whole docs to make them more clear; replaced "snapshot" with a simplified, custom docker image
BREAKING CHANGE
1 parent 7b6b10f commit 3588cdb

File tree

8 files changed

+576
-425
lines changed

8 files changed

+576
-425
lines changed

README.md

Lines changed: 110 additions & 425 deletions
Large diffs are not rendered by default.

docs/acknowledgments.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Acknowledgments
2+
3+
- Thanks to [Blibla](https://github.com/blib-la) for providing the original repo (previously under `blib-la/runpod-worker-comfy`) to RunPod, to continue the open-source development of this worker.
4+
- Thanks to [all contributors](https://github.com/runpod-workers/worker-comfyui/graphs/contributors) for your awesome work.
5+
- Thanks to [Justin Merrell](https://github.com/justinmerrell) from RunPod for [worker-1111](https://github.com/runpod-workers/worker-a1111), which was used to get inspired on how to create this worker.
6+
- Thanks to [Ashley Kleynhans](https://github.com/ashleykleynhans) for [runpod-worker-a1111](https://github.com/ashleykleynhans/runpod-worker-a1111), which was used to get inspired on how to create this worker.
7+
- Thanks to [comfyanonymous](https://github.com/comfyanonymous) for creating [ComfyUI](https://github.com/comfyanonymous/ComfyUI), which provides such an awesome API to interact with Stable Diffusion and beyond.

docs/ci-cd.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# CI/CD
2+
3+
This project includes GitHub Actions workflows to automatically build and deploy Docker images to Docker Hub.
4+
5+
## Automatic Deployment to Docker Hub with GitHub Actions
6+
7+
The repository contains two workflows located in the `.github/workflows` directory:
8+
9+
- [`dev.yml`](../.github/workflows/dev.yml): Creates the images (base, sdxl, sd3, flux variants) and pushes them to Docker Hub tagged as `<image_name>:dev` on every push to the `main` branch.
10+
- [`release.yml`](../.github/workflows/release.yml): Creates the images and pushes them to Docker Hub tagged as `<image_name>:latest` and `<image_name>:<release_version>` (e.g., `worker-comfyui:3.7.0`). This workflow is triggered only when a new release is created on GitHub.
11+
12+
### Configuration for Your Fork
13+
14+
If you have forked this repository and want to use these actions to publish images to your own Docker Hub account, you need to configure the following in your GitHub repository settings:
15+
16+
1. **Secrets** (`Settings > Secrets and variables > Actions > New repository secret`):
17+
18+
| Secret Name | Description | Example Value |
19+
| -------------------------- | -------------------------------------------------------------------------- | ------------------- |
20+
| `DOCKERHUB_USERNAME` | Your Docker Hub username. | `your-dockerhub-id` |
21+
| `DOCKERHUB_TOKEN` | Your Docker Hub access token with read/write permissions. | `dckr_pat_...` |
22+
| `HUGGINGFACE_ACCESS_TOKEN` | Your READ access token from Hugging Face (required only for building SD3). | `hf_...` |
23+
24+
2. **Variables** (`Settings > Secrets and variables > Actions > New repository variable`):
25+
26+
| Variable Name | Description | Example Value |
27+
| ---------------- | ---------------------------------------------------------------------------- | -------------------------- |
28+
| `DOCKERHUB_REPO` | The target repository (namespace) on Docker Hub where images will be pushed. | `your-dockerhub-id` |
29+
| `DOCKERHUB_IMG` | The base name for the image to be pushed to Docker Hub. | `my-custom-worker-comfyui` |
30+
31+
With these secrets and variables configured, the actions will push the built images (e.g., `your-dockerhub-id/my-custom-worker-comfyui:dev`, `your-dockerhub-id/my-custom-worker-comfyui:1.0.0`, `your-dockerhub-id/my-custom-worker-comfyui:latest`) to your Docker Hub account when triggered.

docs/configuration.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Configuration
2+
3+
This document outlines the environment variables available for configuring the `worker-comfyui`.
4+
5+
## General Configuration
6+
7+
| Environment Variable | Description | Default |
8+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
9+
| `REFRESH_WORKER` | When `true`, the worker pod will stop after each completed job to ensure a clean state for the next job. See the [RunPod documentation](https://docs.runpod.io/docs/handler-additional-controls#refresh-worker) for details. | `false` |
10+
| `SERVE_API_LOCALLY` | When `true`, enables a local HTTP server simulating the RunPod environment for development and testing. See the [Development Guide](development.md#local-api) for more details. | `false` |
11+
12+
## AWS S3 Upload Configuration
13+
14+
Configure these variables **only** if you want the worker to upload generated images directly to an AWS S3 bucket. If these are not set, images will be returned as base64-encoded strings in the API response.
15+
16+
- **Prerequisites:**
17+
- An AWS S3 bucket in your desired region.
18+
- An AWS IAM user with programmatic access (Access Key ID and Secret Access Key).
19+
- Permissions attached to the IAM user allowing `s3:PutObject` (and potentially `s3:PutObjectAcl` if you need specific ACLs) on the target bucket.
20+
21+
| Environment Variable | Description | Example |
22+
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
23+
| `BUCKET_ENDPOINT_URL` | The full endpoint URL of your S3 bucket. **Must be set to enable S3 upload.** | `https://<your-bucket-name>.s3.<aws-region>.amazonaws.com` |
24+
| `BUCKET_ACCESS_KEY_ID` | Your AWS access key ID associated with the IAM user that has write permissions to the bucket. Required if `BUCKET_ENDPOINT_URL` is set. | `AKIAIOSFODNN7EXAMPLE` |
25+
| `BUCKET_SECRET_ACCESS_KEY` | Your AWS secret access key associated with the IAM user. Required if `BUCKET_ENDPOINT_URL` is set. | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` |
26+
27+
**Note:** Upload uses the `runpod` Python library helper `rp_upload.upload_image`, which handles creating a unique path within the bucket based on the `job_id`.
28+
29+
### Example S3 Response
30+
31+
If the S3 environment variables (`BUCKET_ENDPOINT_URL`, `BUCKET_ACCESS_KEY_ID`, `BUCKET_SECRET_ACCESS_KEY`) are correctly configured, a successful job response will look similar to this:
32+
33+
```json
34+
{
35+
"id": "sync-uuid-string",
36+
"status": "COMPLETED",
37+
"output": {
38+
"images": [
39+
{
40+
"filename": "ComfyUI_00001_.png",
41+
"type": "s3_url",
42+
"data": "https://your-bucket-name.s3.your-region.amazonaws.com/sync-uuid-string/ComfyUI_00001_.png"
43+
}
44+
// Additional images generated by the workflow would appear here
45+
]
46+
// The "errors" key might be present here if non-fatal issues occurred
47+
},
48+
"delayTime": 123,
49+
"executionTime": 4567
50+
}
51+
```
52+
53+
The `data` field contains the presigned URL to the uploaded image file in your S3 bucket. The path usually includes the job ID.

docs/customization.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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

Comments
 (0)