Skip to content

Commit 0cee22c

Browse files
authored
feat(dev): add Ansible playbook for ComfyStream setup (#114)
This commit adds an Ansible playbook for automated ComfyStream setup, switches Caddy release to `stable`, and prevents cloud-init from duplicating import lines. Also introduces a `--bare-vm` option for deploying a clean TensorDock instance without ComfyStream and refines cloud-init template behavior for better reliability.
1 parent d6b84ed commit 0cee22c

File tree

8 files changed

+480
-115
lines changed

8 files changed

+480
-115
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This repo also includes a WebRTC server and UI that uses comfystream to support
1010
- [Docker Image](#docker-image)
1111
- [RunPod](#runpod)
1212
- [Tensordock](#tensordock)
13+
- [Other Cloud Providers](#other-cloud-providers)
1314
- [Download Models](#download-models)
1415
- [Install package](#install-package)
1516
- [Custom Nodes](#custom-nodes)
@@ -42,11 +43,15 @@ The RunPod template [livepeer-comfystream](https://runpod.io/console/deploy?temp
4243

4344
#### Tensordock
4445

45-
We also have a python script that can be used to spin up a ComfyStream instance on a [Tensordock server](https://tensordock.com/). Refer to [scripts/README.md](scripts/README.md) for instructions.
46+
We also have a python script that can be used to spin up a ComfyStream instance on a [Tensordock server](https://tensordock.com/). Refer to [scripts/README.md](./scripts/README.md#tensordock-auto-setup-fully-automated) for instructions.
47+
48+
#### Other Cloud Providers
49+
50+
We also provide an [Ansible playbook](https://docs.ansible.com/ansible/latest/installation_guide/index.html) for deploying ComfyStream on any cloud provider. Refer to [scripts/README.md](./scripts/README.md#cloud-agnostic-automated-setup-ansible-based-deployment) for instructions.
4651

4752
## Download Models
4853

49-
Refer to [src/comfystream/scripts/README.md](src/comfystream/scripts/README.md) for instructions to download commonly used models.
54+
Refer to [scripts/README.md](src/comfystream/scripts/README.md) for instructions to download commonly used models.
5055

5156
## Install package
5257

@@ -83,7 +88,7 @@ pip install git+https://github.com/yondonfu/comfystream.git
8388

8489
### Custom Nodes
8590

86-
comfystream uses a few auxiliary custom nodes to support running workflows.
91+
Comfystream uses a few auxiliary custom nodes to support running workflows.
8792

8893
**Note:** If you are using comfystream as a custom node in ComfyUI, you can skip the following steps.
8994

scripts/README.md

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,108 @@
11
# ComfyUI Helper Scripts
22

3-
This directory contains various helper scripts designed to streamline working with ComfyStream:
3+
This directory contains helper scripts to simplify the deployment and management of **ComfyStream**:
44

5-
- `spinup_comfystream_tensordock.py`: Spins up a ComfyStream instance on a [Tensordock server](https://tensordock.com/), installs dependencies, and starts the server.
5+
- **Ansible Playbook (`ansible/plays/setup_comfystream.yml`)** – Deploys ComfyStream on any cloud provider.
6+
- **`spinup_comfystream_tensordock.py`** – Fully automates VM creation and ComfyStream setup on a [TensorDock server](https://tensordock.com/).
67

78
## Usage Instructions
89

9-
### Spinup TensorDock ComfyStream Instance
10+
### Ansible Playbook (Cloud-Agnostic Deployment)
1011

11-
1. **Create a Tensordock Account**: Register at [Tensordock](https://dashboard.tensordock.com/register), attach a credit card, and create an API key and token.
12-
2. **Set Up a Python Virtual Environment**:
13-
Create and activate a virtual environment using [Conda](https://docs.anaconda.com/miniconda/) and install the required dependencies:
12+
This repository includes an [Ansible playbook](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html) to deploy ComfyStream on any cloud provider. Follow the steps below:
13+
14+
1. **Create a VM**:
15+
Deploy a VM on a cloud provider such as [TensorDock](https://marketplace.tensordock.com/deploy?gpu=geforcertx4090-pcie-24gb&gpuCount=1&ramAmount=16&vcpuCount=4&storage=100&os=Ubuntu-22.04-LTS), AWS, Google Cloud, or Azure with the following minimum specifications:
16+
- **GPU**: 20GB VRAM
17+
- **RAM**: 16GB
18+
- **CPU**: 4 vCPUs
19+
- **Storage**: 100GB
20+
21+
> [!TIP]
22+
> You can use the `spinup_comfystream_tensordock.py --bare-vm` script to create a [compatible VM on TensorDock](https://marketplace.tensordock.com/deploy?gpu=geforcertx4090-pcie-24gb&gpuCount=1&ramAmount=16&vcpuCount=4&storage=100&os=Ubuntu-22.04-LTS)
23+
24+
2. **Open Required Ports**:
25+
Ensure the following ports are open **inbound and outbound** on the VM's firewall/security group:
26+
- **SSH (Port 22)** – Remote access
27+
- **HTTPS (Port 8189)** – ComfyStream access
28+
29+
3. **Install Ansible**:
30+
Follow the [official Ansible installation guide](https://docs.ansible.com/ansible/latest/installation_guide/index.html).
31+
32+
4. **Configure the Inventory File**:
33+
Add the VM’s public IP to `ansible/inventory.yml`.
34+
35+
5. **Change the ComfyUI Password:**
36+
Open the `ansible/plays/setup_comfystream.yaml` file and replace the `comfyui_password` value with your own secure password.
37+
38+
6. **Run the Playbook**:
39+
Execute:
1440

1541
```bash
16-
conda create -n comfystream python=3.8
17-
conda activate comfystream
18-
pip install -r requirements.txt
42+
ansible-playbook -i ansible/inventory.yaml ansible/plays/setup_comfystream.yaml
1943
```
2044

21-
3. **Check Available Options** *(Optional but Recommended)*:
22-
To see all available script options, run:
45+
> [!IMPORTANT]
46+
> When using a non-sudo user, add `--ask-become-pass` to provide the sudo password or use an Ansible vault for secure storage.
47+
48+
7. Access the Server:
49+
Once the **Ansible playbook** completes successfully, the **ComfyStream** container will start, downloading models and building TensorRT engines. When ready, access **ComfyUI** at `https://<VM_IP>:<PORT_THAT_FORWARDS_TO_8189>`.
50+
51+
> [!IMPORTANT]
52+
> If you encounter a `toomanyrequests` error while pulling the Docker image, either wait a few minutes or provide your Docker credentials when running the playbook:
53+
>
54+
> ```bash
55+
> ansible-playbook -i ansible/inventory.yaml ansible/plays/setup_comfystream.yaml -e "docker_hub_username=your_dockerhub_username docker_hub_password=your_dockerhub_pat"
56+
> ```
57+
58+
> [!TIP]
59+
> The [ComfyStream Docker image](https://hub.docker.com/r/livepeer/comfystream/tags) is **~20GB**. To check download progress, SSH into the VM and run:
60+
>
61+
> ```bash
62+
> docker pull livepeer/comfystream:latest
63+
> ```
64+
65+
### TensorDock Spinup Script (Fully Automated)
66+
67+
The `spinup_comfystream_tensordock.py` script automates VM provisioning, setup, and server launch on [TensorDock](https://tensordock.com/). Follow the steps below:
68+
69+
1. **Create a TensorDock Account**: Sign up at [Tensordock](https://dashboard.tensordock.com/register), add a payment method, and generate API credentials.
70+
71+
2. **Set Up a Python Virtual Environment**:
72+
To prevent dependency conflicts, create and activate a virtual environment with [Conda](https://docs.anaconda.com/miniconda/) and install the required dependencies:
73+
74+
```bash
75+
conda create -n comfystream python=3.8
76+
conda activate comfystream
77+
pip install -r requirements.txt
78+
```
79+
80+
3. **View Available Script Options** *(Optional)*:
81+
To see all available options, run:
2382

2483
```bash
2584
python spinup_comfystream_tensordock.py --help
2685
```
2786

2887
4. **Run the Script**:
29-
Execute the following command to spin up a ComfyStream instance:
88+
Execute the following command to provision a VM and set up ComfyStream automatically:
3089

3190
```bash
3291
python spinup_comfystream_tensordock.py --api-key <API_KEY> --api-token <API_TOKEN>
3392
```
3493

3594
5. **Access the Server**:
36-
The script will set up the instance, install dependencies, and start the server. This process will take a few minutes. Once completed, you can access the ComfyStream server and UI using the provided URLs.
95+
Once the setup is complete, the script will display the URLs to access ComfyStream.
3796

38-
6. **Stop the Server**:
39-
To stop the server, run:
97+
6. **Stop & Delete the VM** *(When No Longer Needed)*:
98+
To stop and remove the instance, run:
4099

41100
```bash
42101
python spinup_comfystream_tensordock.py --delete <VM_ID>
43102
```
44103

45-
Replace `<VM_ID>` with the ID of the VM you want to delete. You can find the VM ID in the script logs or the [Tensordock dashboard](https://dashboard.tensordock.com/).
104+
Replace `<VM_ID>` with the VM ID found in the script logs or the [TensorDock dashboard](https://dashboard.tensordock.com/instances).
46105

47106
> [!WARNING]
48-
> If you see `max retries exceeded with url` errors, the VM was likely created but is inaccessible. Check the [TensorDock dashboard](https://dashboard.tensordock.com/instances), delete the VM, wait 2-3 minutes, then run the script again.
107+
> If you encounter `max retries exceeded with URL` errors, the VM might have been created but is inaccessible.
108+
> Check the [TensorDock dashboard](https://dashboard.tensordock.com/instances), delete the VM manually, wait **2-3 minutes**, then rerun the script.

scripts/ansible/inventory.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
all:
3+
hosts:
4+
comfystream_vm:
5+
ansible_host: 123.234.102.170 # Replace with your VM's IP address
6+
ansible_port: 22 # Replace with your VM's SSH port
7+
ansible_user: user # Replace with your SSH user
8+
ansible_ssh_private_key_file: ~/.ssh/private_key # Path to your SSH key

0 commit comments

Comments
 (0)