Hello everyone, I am the daydreamer Nexmoe. Recently, I have open-sourced a ComfyUI elastic Serverless application packaged based on Docker, which features a complete front-end and back-end separation architecture and a user-friendly interface.
After completing the development of the ComfyUI workflow, deploying it to a production environment can be quite tricky. Therefore, I have open-sourced a set of examples for everyone to learn from.
Demo: https://hadoop.nexmoe.com/
Open-source address: https://github.com/nexmoe/serverless-comfyui
Project Features#
- 🐳 Complete Docker deployment solution
- 🎨 Modern front-end interface
- 🔌 Modular back-end architecture
- 🛠 Simple configuration and usage
Architecture Diagram#
Project Structure#
The directory structure of frontend/ is as follows, models and custom nodes need to be downloaded and installed manually.
Environment Requirements#
- Docker & Docker Compose
- NVIDIA GPU (current demo workflow requires more than 12G of VRAM)
- Sufficient disk space (100G~200G) for storing models
Quick Start#
Local Testing of Backend#
- Navigate to the backend Dockerfile directory
- Download model files
Please refer to: https://gongjiyun.com/docs/tutorials/comfyui.html#%E4%B8%8B%E8%BD%BD%E6%A8%A1%E5%9E%8B%E5%92%8C%E6%89%A9%E5%B1%95
- Build the Docker image
- Run the Docker container
After the container starts, you can access:
- ComfyUI interface: http://localhost:8188
- API interface: http://localhost:3000/docs
Local Testing of Frontend#
- Navigate to the frontend directory
- Configure environment variables
- Install dependencies and start
Deploying ComfyUI Docker to Serverless Elastic Platform#
Please refer to Gongji Technology's ComfyUI deployment documentation
API Documentation#
The project uses Bruno for API testing and documentation management, with related files located in the bruno/ directory.
Example of ComfyUI API Call#
Here is an example code for calling the ComfyUI API (refer to frontend/src/app/api/route.ts):
Main steps explanation:
-
Prepare Prompt:
- Import base prompt configuration from JSON file
- Modify parameters in the prompt as needed (e.g., input image)
-
Send Request:
- Use POST method
- Set Content-Type to application/json
- Request body is serialized prompt data
-
Process Response:
- Check response status code
- Parse returned JSON data
- Extract generated image (base64 format)
-
Error Handling:
- Log error messages
- Throw appropriate error messages
Environment Variable Configuration#
Before using the API, ensure to configure the following environment variables:
S3 Configuration Instructions#
The project's image upload feature requires configuring S3 storage services. You can use AWS S3 or other object storage services compatible with S3 protocol (like MinIO).
Configure the following environment variables in the frontend/.env file:
Note:
- Ensure the created bucket has appropriate access permissions
- If using MinIO, the endpoint should be a complete URL (e.g., http://localhost:9000)
- When using AWS S3, the endpoint configuration can be omitted
Contribution Guidelines#
Feel free to submit Issues and Pull Requests!
License#
MIT License