Nexmoe

Nexmoe

一个开发者。关于勇敢与热爱,互联网/创造/赛博朋克
twitter
github

How to Deploy ComfyUI Docker Image to Production Environment

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#

Mermaid Loading...

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#

  1. Navigate to the backend Dockerfile directory
  1. 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

  1. Build the Docker image
  1. Run the Docker container

After the container starts, you can access:

Local Testing of Frontend#

  1. Navigate to the frontend directory
  1. Configure environment variables
  1. 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:

  1. Prepare Prompt:

    • Import base prompt configuration from JSON file
    • Modify parameters in the prompt as needed (e.g., input image)
  2. Send Request:

    • Use POST method
    • Set Content-Type to application/json
    • Request body is serialized prompt data
  3. Process Response:

    • Check response status code
    • Parse returned JSON data
    • Extract generated image (base64 format)
  4. 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

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.