From b3af4ee50b68c93e2807cf67ff39202dbbe7a7be Mon Sep 17 00:00:00 2001 From: Ankit Matth Date: Sun, 24 Aug 2025 08:59:19 +0530 Subject: [PATCH] speed up scripts by using docker hub --- deployment/docker-compose-hub.yaml | 71 ++++++++++++++++++++++++++++++ setup.ps1 | 24 +++++----- setup.sh | 10 ++--- 3 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 deployment/docker-compose-hub.yaml diff --git a/deployment/docker-compose-hub.yaml b/deployment/docker-compose-hub.yaml new file mode 100644 index 00000000..517fb68e --- /dev/null +++ b/deployment/docker-compose-hub.yaml @@ -0,0 +1,71 @@ +name: docsgpt-oss +services: + frontend: + image: arc53/docsgpt:develop # some changes required here + environment: + - VITE_API_HOST=http://localhost:7091 + - VITE_API_STREAMING=$VITE_API_STREAMING + ports: + - "5173:5173" + depends_on: + - backend + + backend: + user: root + image: arc53/docsgpt:develop # some changes required here + environment: + - API_KEY=$API_KEY + - EMBEDDINGS_KEY=$API_KEY + - LLM_PROVIDER=$LLM_PROVIDER + - LLM_NAME=$LLM_NAME + - CELERY_BROKER_URL=redis://redis:6379/0 + - CELERY_RESULT_BACKEND=redis://redis:6379/1 + - MONGO_URI=mongodb://mongo:27017/docsgpt + - CACHE_REDIS_URL=redis://redis:6379/2 + - OPENAI_BASE_URL=$OPENAI_BASE_URL + ports: + - "7091:7091" + volumes: + - ../application/indexes:/app/indexes + - ../application/inputs:/app/inputs + - ../application/vectors:/app/vectors + depends_on: + - redis + - mongo + + worker: + user: root + image: arc53/docsgpt:develop # some changes required here + command: celery -A application.app.celery worker -l INFO -B + environment: + - API_KEY=$API_KEY + - EMBEDDINGS_KEY=$API_KEY + - LLM_PROVIDER=$LLM_PROVIDER + - LLM_NAME=$LLM_NAME + - CELERY_BROKER_URL=redis://redis:6379/0 + - CELERY_RESULT_BACKEND=redis://redis:6379/1 + - MONGO_URI=mongodb://mongo:27017/docsgpt + - API_URL=http://backend:7091 + - CACHE_REDIS_URL=redis://redis:6379/2 + volumes: + - ../application/indexes:/app/indexes + - ../application/inputs:/app/inputs + - ../application/vectors:/app/vectors + depends_on: + - redis + - mongo + + redis: + image: redis:6-alpine + ports: + - 6379:6379 + + mongo: + image: mongo:6 + ports: + - 27017:27017 + volumes: + - mongodb_data_container:/data/db + +volumes: + mongodb_data_container: diff --git a/setup.ps1 b/setup.ps1 index 8572484f..01a969ab 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -9,7 +9,7 @@ $ErrorActionPreference = "Stop" # Get current script directory $SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition -$COMPOSE_FILE = Join-Path -Path $SCRIPT_DIR -ChildPath "deployment\docker-compose.yaml" +$COMPOSE_FILE = Join-Path -Path $SCRIPT_DIR -ChildPath "deployment\docker-compose-hub.yaml" $ENV_FILE = Join-Path -Path $SCRIPT_DIR -ChildPath ".env" # Function to write colored text @@ -304,9 +304,9 @@ function Use-DocsPublicAPIEndpoint { # Run Docker compose commands try { - & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" build + & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull if ($LASTEXITCODE -ne 0) { - throw "Docker compose build failed with exit code $LASTEXITCODE" + throw "Docker compose pull failed with exit code $LASTEXITCODE" } & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d @@ -415,10 +415,10 @@ function Serve-LocalOllama { Write-Host "" Write-ColorText "Starting Docker Compose with Ollama ($docker_compose_file_suffix)..." -ForegroundColor "White" - # Build the containers - & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" -f "$optional_compose" build + # Pull the containers + & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" -f "$optional_compose" pull if ($LASTEXITCODE -ne 0) { - throw "Docker compose build failed with exit code $LASTEXITCODE" + throw "Docker compose pull failed with exit code $LASTEXITCODE" } # Start the containers @@ -575,10 +575,10 @@ function Connect-LocalInferenceEngine { Write-Host "" Write-ColorText "Starting Docker Compose..." -ForegroundColor "White" - # Build the containers - & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" build + # Pull the containers + & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull if ($LASTEXITCODE -ne 0) { - throw "Docker compose build failed with exit code $LASTEXITCODE" + throw "Docker compose pull failed with exit code $LASTEXITCODE" } # Start the containers @@ -706,10 +706,12 @@ function Connect-CloudAPIProvider { Write-ColorText "Starting Docker Compose..." -ForegroundColor "White" # Run Docker compose commands - & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d --build + & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull if ($LASTEXITCODE -ne 0) { - throw "Docker compose build or up failed with exit code $LASTEXITCODE" + throw "Docker compose pull failed with exit code $LASTEXITCODE" } + + & docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d Write-Host "" Write-ColorText "DocsGPT is now configured to use $provider_name on http://localhost:5173" -ForegroundColor "Green" diff --git a/setup.sh b/setup.sh index b072d546..f322884e 100755 --- a/setup.sh +++ b/setup.sh @@ -9,7 +9,7 @@ NC='\033[0m' BOLD='\033[1m' # Base Compose file (relative to script location) -COMPOSE_FILE="$(dirname "$(readlink -f "$0")")/deployment/docker-compose.yaml" +COMPOSE_FILE="$(dirname "$(readlink -f "$0")")/deployment/docker-compose-hub.yaml" ENV_FILE="$(dirname "$(readlink -f "$0")")/.env" # Animation function @@ -176,7 +176,7 @@ use_docs_public_api_endpoint() { check_and_start_docker echo -e "\n${NC}Starting Docker Compose...${NC}" - docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" build && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d + docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d docker_compose_status=$? # Capture exit status of docker compose echo "Docker Compose Exit Status: $docker_compose_status" @@ -252,7 +252,7 @@ serve_local_ollama() { ) echo -e "\n${NC}Starting Docker Compose with Ollama (${docker_compose_file_suffix})...${NC}" - docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" build + docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" pull docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" up -d docker_compose_status=$? @@ -360,7 +360,7 @@ connect_local_inference_engine() { check_and_start_docker echo -e "\n${NC}Starting Docker Compose...${NC}" - docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" build && docker compose -f "${COMPOSE_FILE}" up -d + docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose -f "${COMPOSE_FILE}" up -d docker_compose_status=$? echo "Docker Compose Exit Status: $docker_compose_status" # Debug output @@ -449,7 +449,7 @@ connect_cloud_api_provider() { check_and_start_docker echo -e "\n${NC}Starting Docker Compose...${NC}" - docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d --build + docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d docker_compose_status=$? echo "Docker Compose Exit Status: $docker_compose_status" # Debug output