From cc25b5e85647b7e65f82e87adbf6bb5aebe79de0 Mon Sep 17 00:00:00 2001 From: shatanikmahanty Date: Fri, 11 Oct 2024 11:37:12 +0530 Subject: [PATCH 1/2] Feat: Add ability to start docker if it's not running --- setup.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 988841da4..7b06190ce 100755 --- a/setup.sh +++ b/setup.sh @@ -9,6 +9,54 @@ prompt_user() { read -p "Enter your choice (1, 2 or 3): " choice } +check_and_start_docker() { + # Check if Docker is running + if ! docker info > /dev/null 2>&1; then + echo "Docker is not running. Starting Docker..." + + # Check the operating system + case "$(uname -s)" in + Darwin) + open -a Docker + ;; + Linux) + sudo systemctl start docker + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) + echo "Detected Windows." + + # Check if Docker Desktop is located at the default path + DOCKER_DESKTOP_PATH="/c/Program Files/Docker/Docker/Docker Desktop.exe" + + if [ -f "$DOCKER_DESKTOP_PATH" ]; then + echo "Starting Docker Desktop..." + "$DOCKER_DESKTOP_PATH" & + else + echo "Docker Desktop not found at the default location." + echo "Please start Docker Desktop manually." + exit 1 + fi + ;; + *) + echo "Unsupported platform. Please start Docker manually." + exit 1 + ;; + esac + + # Wait for Docker to be fully operational with animated dots + echo -n "Waiting for Docker to start" + while ! docker system info > /dev/null 2>&1; do + for i in {1..3}; do + echo -n "." + sleep 1 + done + echo -ne "\rWaiting for Docker to start " # Reset to overwrite previous dots + done + + echo -e "\nDocker has started!" + fi +} + # Function to handle the choice to download the model locally download_locally() { echo "LLM_NAME=llama.cpp" > .env @@ -30,6 +78,9 @@ download_locally() { echo "Model already exists." fi + # Call the function to check and start Docker if needed + check_and_start_docker + docker-compose -f docker-compose-local.yaml build && docker-compose -f docker-compose-local.yaml up -d #python -m venv venv #source venv/bin/activate @@ -59,10 +110,11 @@ use_openai() { echo "VITE_API_STREAMING=true" >> .env echo "The .env file has been created with API_KEY set to your provided key." + # Call the function to check and start Docker if needed + check_and_start_docker + docker-compose build && docker-compose up -d - - echo "The application will run on http://localhost:5173" echo "You can stop the application by running the following command:" echo "docker-compose down" @@ -73,6 +125,9 @@ use_docsgpt() { echo "VITE_API_STREAMING=true" >> .env echo "The .env file has been created with API_KEY set to your provided key." + # Call the function to check and start Docker if needed + check_and_start_docker + docker-compose build && docker-compose up -d echo "The application will run on http://localhost:5173" From ec5db5d2c7ac2625765b15672f48419ebea081d4 Mon Sep 17 00:00:00 2001 From: shatanikmahanty Date: Fri, 11 Oct 2024 11:50:18 +0530 Subject: [PATCH 2/2] Refactor: remove docker start script for windows platform --- setup.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/setup.sh b/setup.sh index 7b06190ce..7980461b6 100755 --- a/setup.sh +++ b/setup.sh @@ -22,21 +22,6 @@ check_and_start_docker() { Linux) sudo systemctl start docker ;; - CYGWIN*|MINGW32*|MSYS*|MINGW*) - echo "Detected Windows." - - # Check if Docker Desktop is located at the default path - DOCKER_DESKTOP_PATH="/c/Program Files/Docker/Docker/Docker Desktop.exe" - - if [ -f "$DOCKER_DESKTOP_PATH" ]; then - echo "Starting Docker Desktop..." - "$DOCKER_DESKTOP_PATH" & - else - echo "Docker Desktop not found at the default location." - echo "Please start Docker Desktop manually." - exit 1 - fi - ;; *) echo "Unsupported platform. Please start Docker manually." exit 1