From 34b77380c277b3730f59f1f0226cd961ecb3dc29 Mon Sep 17 00:00:00 2001 From: RedsAnalysis Date: Sat, 15 Mar 2025 06:26:59 -0400 Subject: [PATCH] Added ComfyUI-Manager support, made changes to .sh file to create volume for custom_nodes --- Dockerfile | 2 +- docker-build.sh | 29 ++++++++++++++++++++++------- docker-compose.yml | 5 +++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index c78c0c2d..52d1e210 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,4 +58,4 @@ RUN . venv/bin/activate && pip install -r /app/comfyui/custom_nodes/ComfyUI-Mana EXPOSE 8188 # Set the entrypoint command to activate the virtual environment and run the script -CMD ["/bin/bash", "-c", "source /app/venv/bin/activate && python3 /app/comfyui/main.py --listen 0.0.0.0 --port 8188 && echo 'Server started and ready to accept requests'"] +CMD ["/bin/bash", "-c", "source /app/venv/bin/activate && python3 /app/comfyui/main.py --listen 0.0.0.0 --port 8188"] diff --git a/docker-build.sh b/docker-build.sh index 5c20d985..cdffdb8b 100644 --- a/docker-build.sh +++ b/docker-build.sh @@ -58,6 +58,21 @@ else exit 1 fi +# Step 4: Copy the 'ComfyUI-Manager' directory from the container to the host +echo "Checking if /app/comfyui/custom_nodes/ComfyUI-Manager exists in the container..." +if docker exec "$container_name" ls /app/comfyui/custom_nodes/ComfyUI-Manager; then + echo "Copying the ComfyUI-Manager from the container to the host..." + if ! docker cp "$container_name:/app/comfyui/custom_nodes/ComfyUI-Manager" ./custom_nodes/ComfyUI-Manager; then + echo "Failed to copy the ComfyUI-Manager. Exiting." + exit 1 + else + echo "ComfyUI-Manager copied successfully." + fi +else + echo "/app/comfyui/custom_nodes/ComfyUI-Manager does not exist in the container. Exiting." + exit 1 +fi + # Step 5: Stop the container echo "Stopping the container..." docker-compose down @@ -72,20 +87,20 @@ fi echo "Updating Docker Compose file to mount the virtual environment..." sed -i '/# Mount the venv directory for persistence/a \ \ \ \ \ \ - ./venv:/app/venv' docker-compose.yml if [ $? -eq 0 ]; then - echo "Docker Compose file updated successfully." + echo "Docker Compose file updated to include venv." else echo "Failed to update Docker Compose file. Exiting." exit 1 fi -# Step 7: Restart the container with the venv volume mounted -echo "Restarting the container with the virtual environment mounted..." -docker-compose up -d +# Step 6: Update the Docker Compose file to mount the venv volume +echo "Updating Docker Compose file to mount the custom_nodes..." +sed -i '/# Mount the custom nodes directory directly inside/a \ \ \ \ \ \ - ./custom_nodes:/app/comfyui/custom_nodes' docker-compose.yml if [ $? -eq 0 ]; then - echo "Container restarted successfully." + echo "Docker Compose file updated to include custom_nodes." else - echo "Failed to restart the container. Exiting." + echo "Failed to update Docker Compose file. Exiting." exit 1 fi -echo "Setup complete! The container is running with the virtual environment persisted at ./venv." \ No newline at end of file +echo "Setup complete! you can use "docker-compose up" to start the container." \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index be888196..34b9b715 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,11 +11,12 @@ services: - ./input:/app/comfyui/input # Mount the input directory directly inside /app/comfyui - ./models:/app/comfyui/models # Mount the models directory directly inside /app/comfyui - ./output:/app/comfyui/output # Mount the output directory directly inside /app/comfyui - - ./custom_nodes:/app/comfyui/custom_nodes # Mount the custom nodes directory directly inside /app/comfyui - ./user:/app/comfyui/user # Comment this line and uncomment the next line if you want to have a workflows directory in the root directory. #- ./workflows:/app/comfyui/user/default/workflows - # Mount the venv directory for persistence(automatically mounted with you run docker-build.sh) + # Mount the venv directory for persistence (automatically mounted with you run docker-build.sh) + + # Mount the custom nodes directory directly inside /app/comfyui (automatically mounted with you run docker-build.sh) environment: