Skip to content

Deployment Overview of ComfyUI on Server

Prerequisites and Basic Requirements

The deployment requires a Debian-based operating system with root privileges. The following components must be available on the server:

  • Python 3 and pip package manager.
  • Network access to download PyTorch wheels from the official repository.
  • Network access to download model files from the specified internal or external sources.
  • Systemd service manager for process control.
  • Docker and Docker Compose for the reverse proxy and SSL certificate management.

File and Directory Structure

The application and its configuration files are organized in the following locations:

  • Application Source: /root/ComfyUI
  • Model Checkpoints: /root/ComfyUI/models/checkpoints
  • User Workflows: /root/ComfyUI/user/default/workflows
  • Application Settings: /root/ComfyUI/user/default/comfy.settings.json
  • Systemd Service File: /etc/systemd/system/comfyui.service
  • Nginx Configuration Directory: /root/nginx
  • Nginx Compose File: /root/nginx/compose.yml
  • Nginx Environment File: /data/nginx/nginx-certbot.env
  • Nginx User Configuration: /data/nginx/user_conf.d

Application Installation Process

The ComfyUI application is installed by cloning the official repository and installing Python dependencies. The installation process includes:

  1. Cloning the repository from https://github.com/comfyanonymous/ComfyUI.git to /root/ComfyUI.
  2. Installing python3-pip via the APT package manager.
  3. Installing PyTorch with CUDA 12.6 support using the command:
    /usr/bin/pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
    
  4. Installing application requirements from the requirements.txt file located in the /root/ComfyUI directory.
  5. Downloading the Flux model file (flux1-dev-fp8.safetensors) to the checkpoints directory.
  6. Creating the workflows directory at /root/ComfyUI/user/default/workflows.
  7. Deploying the workflow configuration file flux1-dev-fp8.json into the workflows directory.
  8. Configuring the application settings in comfy.settings.json with the following parameters:
  9. Comfy.NodeLibrary.Bookmarks: Empty array
  10. Comfy.UseNewMenu: Top
  11. Comfy.DevMode: false
  12. Comfy.Locale: en

Access Rights and Security

Network access to the application is managed through the following configurations:

  • The IP address 5.180.174.199 is mapped to the domain huggingface.co in the /etc/hosts file to facilitate model downloads.
  • The application runs as a background service managed by systemd.
  • The reverse proxy and SSL termination are handled by a Docker container running Nginx with Certbot.

Docker Containers and Their Deployment

A Docker container is deployed to manage the Nginx reverse proxy and SSL certificates. The deployment uses the following configuration:

  • Image: jonasal/nginx-certbot:latest
  • Restart Policy: unless-stopped
  • Network Mode: host
  • Environment Variables:
  • CERTBOT_EMAIL: [email protected]
  • Volumes:
  • nginx_secrets mapped to /etc/letsencrypt
  • /data/nginx/user_conf.d mapped to /etc/nginx/user_conf.d

The container is started using the docker compose command executed from the /root/nginx directory.

Proxy Servers

The Nginx reverse proxy is configured to handle SSL certificates via Certbot. The configuration includes:

  • Email for Certbot: [email protected]
  • Configuration Directory: /data/nginx/user_conf.d
  • Secrets Storage: /etc/letsencrypt (via Docker volume)

The proxy setup ensures that traffic is routed securely to the backend application.

Permission Settings

File and directory permissions are set as follows:

  • The workflows directory /root/ComfyUI/user/default/workflows is set to mode 0755.
  • The workflow JSON file flux1-dev-fp8.json is set to mode 0644.
  • The Nginx directory /root/nginx is owned by root with mode 0644.
  • The Nginx compose file /root/nginx/compose.yml is owned by root with mode 0644.
  • The systemd service file /etc/systemd/system/comfyui.service is owned by root with mode 0644.

Starting, Stopping, and Updating

The ComfyUI application is managed as a systemd service named comfyui. The service is configured to start automatically on boot and is started immediately after deployment.

To manage the service, use the following commands:

  • Start the service:
    systemctl start comfyui
    
  • Stop the service:
    systemctl stop comfyui
    
  • Restart the service:
    systemctl restart comfyui
    
  • Enable the service on boot:
    systemctl enable comfyui
    
  • Check service status:
    systemctl status comfyui
    

The service executes the command /usr/bin/python3 /root/ComfyUI/main.py to run the application.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×