Update docker-build.sh and docker-compose.yml

This commit is contained in:
RedsAnalysis 2025-03-15 02:32:58 -04:00
parent 154fbbd681
commit 1ac7710b8d
2 changed files with 20 additions and 8 deletions

View File

@ -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."

View File

@ -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)