Added Confyui manager to dockerfile, made changes to .sh file to recieve message from main.py, add place holder for venv volume mount

This commit is contained in:
RedsAnalysis 2025-03-15 04:27:18 -04:00
parent 1c6acbaf1f
commit 974d0b1f1a
3 changed files with 77 additions and 14 deletions

View File

@ -46,6 +46,14 @@ RUN . venv/bin/activate && pip install -r /app/comfyui/requirements.txt
# Install PyTorch with CUDA 12.1 support
RUN . venv/bin/activate && pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121
# Clone the ComfyUI-manager repository into a temporary directory, move it, and clean up
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git /app/temp/ComfyUI-Manager && \
mv /app/temp/* /app/comfyui/custom_nodes/ && \
rm -rf /app/temp
# Install ComfyUI-manager dependencies
RUN . venv/bin/activate && pip install -r /app/comfyui/custom_nodes/ComfyUI-Manager/requirements.txt
# Expose the backend port
EXPOSE 8188

View File

@ -7,31 +7,85 @@ then
exit 1
fi
# Step 1: Build and start the container without mounting the venv volume
echo "Building and starting the container to initialize the virtual environment..."
COMPOSE_BAKE=true docker-compose up --build -d
# Step 1: Build the container without using cache
echo "Building the container to initialize the virtual environment..."
COMPOSE_BAKE=true docker-compose build --no-cache
if [ $? -eq 0 ]; then
echo "Build completed successfully."
else
echo "Build failed. Exiting."
exit 1
fi
# Step 2: Start the container without mounting the venv volume
echo "Starting the container..."
COMPOSE_BAKE=true docker-compose up -d
if [ $? -eq 0 ]; then
echo "Container started successfully."
else
echo "Failed to start the container. Exiting."
exit 1
fi
# Step 3: Stream Docker logs to the terminal
container_name="comfyui-red-container"
echo "Streaming Docker logs for container: $container_name..."
docker logs -f "$container_name" &
LOGS_PID=$! # Save the PID of the background process
# Wait for the container logs to indicate it's ready (looking for the custom message)
container_name="comfyui-red-container"
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..."
while ! docker logs "$container_name" 2>&1 | grep -q "To see the GUI go to: http://0.0.0.0:8188"; do
sleep 20
done
# 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
# Stop streaming logs (kill the background process)
kill $LOGS_PID
echo "Container is fully started."
# Step 3: Stop the container
# Step 4: Copy the 'venv' directory from the container to the host
echo "Checking if /app/venv exists in the container..."
if docker exec "$container_name" ls /app/venv; then
echo "Copying the virtual environment from the container to the host..."
if ! docker cp "$container_name:/app/venv" ./venv; then
echo "Failed to copy the virtual environment. Exiting."
exit 1
else
echo "Virtual environment copied successfully."
fi
else
echo "/app/venv does not exist in the container. Exiting."
exit 1
fi
# Step 5: Stop the container
echo "Stopping the container..."
docker-compose down
if [ $? -eq 0 ]; then
echo "Container stopped successfully."
else
echo "Failed to stop the container. Exiting."
exit 1
fi
# Step 4: Update the Docker Compose file to mount the venv volume
# Step 6: 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
if [ $? -eq 0 ]; then
echo "Docker Compose file updated successfully."
else
echo "Failed to update Docker Compose file. Exiting."
exit 1
fi
# Step 5: Restart the container with the venv volume mounted
# Step 7: Restart the container with the venv volume mounted
echo "Restarting the container with the virtual environment mounted..."
docker-compose up -d
if [ $? -eq 0 ]; then
echo "Container restarted successfully."
else
echo "Failed to restart the container. Exiting."
exit 1
fi
echo "Setup complete! The container is running with the virtual environment persisted at ./venv."

View File

@ -15,7 +15,8 @@ services:
- ./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
# Mount the venv directory for persistence(automatically mounted with you run docker-build.sh)
environment:
- DISPLAY=${DISPLAY} # Optional, for X11 display forwarding (if you use it)