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
pippackage 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:
- Cloning the repository from
https://github.com/comfyanonymous/ComfyUI.gitto/root/ComfyUI. - Installing
python3-pipvia the APT package manager. - Installing PyTorch with CUDA 12.6 support using the command:
- Installing application requirements from the
requirements.txtfile located in the/root/ComfyUIdirectory. - Downloading the Flux model file (
flux1-dev-fp8.safetensors) to the checkpoints directory. - Creating the workflows directory at
/root/ComfyUI/user/default/workflows. - Deploying the workflow configuration file
flux1-dev-fp8.jsoninto the workflows directory. - Configuring the application settings in
comfy.settings.jsonwith the following parameters: Comfy.NodeLibrary.Bookmarks: Empty arrayComfy.UseNewMenu:TopComfy.DevMode:falseComfy.Locale:en
Access Rights and Security¶
Network access to the application is managed through the following configurations:
- The IP address
5.180.174.199is mapped to the domainhuggingface.coin the/etc/hostsfile 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_secretsmapped to/etc/letsencrypt/data/nginx/user_conf.dmapped 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/workflowsis set to mode0755. - The workflow JSON file
flux1-dev-fp8.jsonis set to mode0644. - The Nginx directory
/root/nginxis owned byrootwith mode0644. - The Nginx compose file
/root/nginx/compose.ymlis owned byrootwith mode0644. - The systemd service file
/etc/systemd/system/comfyui.serviceis owned byrootwith mode0644.
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:
- Stop the service:
- Restart the service:
- Enable the service on boot:
- Check service status:
The service executes the command /usr/bin/python3 /root/ComfyUI/main.py to run the application.