From 1ac7710b8d28a6a885b02526f8dd558cc06f8e8e Mon Sep 17 00:00:00 2001 From: RedsAnalysis Date: Sat, 15 Mar 2025 02:32:58 -0400 Subject: [PATCH] Update docker-build.sh and docker-compose.yml --- docker-build.sh | 25 ++++++++++++++++++------- docker-compose.yml | 3 ++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docker-build.sh b/docker-build.sh index ff776d75..9c2b6b8f 100644 --- a/docker-build.sh +++ b/docker-build.sh @@ -7,20 +7,31 @@ then exit 1 fi -# Build and start the container +# Step 1: Build and start the container without mounting the venv volume +echo "Building and starting the container to initialize the virtual environment..." docker-compose up --build -d # Wait for the container logs to indicate it's ready (looking for the custom message) -container_name="comfyui-v1" +container_name="comfyui-red-docker" while ! docker logs "$container_name" 2>&1 | grep -q "Server started and ready to accept requests"; do echo "Waiting for the container to be fully started..." - sleep 1 + sleep 20 done -# Copy the 'venv' directory from the container to the host -docker cp "$container_name:/app/venv" ./data/venv +# Step 2: Copy the 'venv' directory from the container to the host +echo "Copying the virtual environment from the container to the host..." +docker cp "$container_name:/app/venv" ./venv -# Optional: Stop the container after everything is set up +# Step 3: Stop the container +echo "Stopping the container..." docker-compose down -echo "The container is set up, and the virtual environment is ready at ./venv." +# Step 4: Update the Docker Compose file to mount the venv volume +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 + +# Step 5: Restart the container with the venv volume mounted +echo "Restarting the container with the virtual environment mounted..." +docker-compose up -d + +echo "Setup complete! The container is running with the virtual environment persisted at ./venv." \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 81b49d79..53813303 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,14 @@ services: ports: - "8188:8188" # Expose the backend API or server volumes: - - ./venv:/app/venv # Mount the venv directory for persistence helps with downloading custom nodes's dependencies from ConfyUI-Manager - ./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 environment: - DISPLAY=${DISPLAY} # Optional, for X11 display forwarding (if you use it)