Skip to content

Commit 44b8a11

Browse files
authored
Merge pull request #1936 from Ankit-Matth/feature/load-containers-from-dockerhub
Speed up scripts by loading containers from docker hub
2 parents 46904cc + 56e5aba commit 44b8a11

File tree

3 files changed

+124
-28
lines changed

3 files changed

+124
-28
lines changed

deployment/docker-compose-hub.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: docsgpt-oss
2+
services:
3+
4+
frontend:
5+
image: arc53/docsgpt-fe:develop
6+
environment:
7+
- VITE_API_HOST=http://localhost:7091
8+
- VITE_API_STREAMING=$VITE_API_STREAMING
9+
ports:
10+
- "5173:5173"
11+
depends_on:
12+
- backend
13+
14+
15+
backend:
16+
user: root
17+
image: arc53/docsgpt:develop
18+
environment:
19+
- API_KEY=$API_KEY
20+
- EMBEDDINGS_KEY=$API_KEY
21+
- LLM_PROVIDER=$LLM_PROVIDER
22+
- LLM_NAME=$LLM_NAME
23+
- CELERY_BROKER_URL=redis://redis:6379/0
24+
- CELERY_RESULT_BACKEND=redis://redis:6379/1
25+
- MONGO_URI=mongodb://mongo:27017/docsgpt
26+
- CACHE_REDIS_URL=redis://redis:6379/2
27+
- OPENAI_BASE_URL=$OPENAI_BASE_URL
28+
ports:
29+
- "7091:7091"
30+
volumes:
31+
- ../application/indexes:/app/indexes
32+
- ../application/inputs:/app/inputs
33+
- ../application/vectors:/app/vectors
34+
depends_on:
35+
- redis
36+
- mongo
37+
38+
39+
worker:
40+
user: root
41+
image: arc53/docsgpt:develop
42+
command: celery -A application.app.celery worker -l INFO -B
43+
environment:
44+
- API_KEY=$API_KEY
45+
- EMBEDDINGS_KEY=$API_KEY
46+
- LLM_PROVIDER=$LLM_PROVIDER
47+
- LLM_NAME=$LLM_NAME
48+
- CELERY_BROKER_URL=redis://redis:6379/0
49+
- CELERY_RESULT_BACKEND=redis://redis:6379/1
50+
- MONGO_URI=mongodb://mongo:27017/docsgpt
51+
- API_URL=http://backend:7091
52+
- CACHE_REDIS_URL=redis://redis:6379/2
53+
volumes:
54+
- ../application/indexes:/app/indexes
55+
- ../application/inputs:/app/inputs
56+
- ../application/vectors:/app/vectors
57+
depends_on:
58+
- redis
59+
- mongo
60+
61+
redis:
62+
image: redis:6-alpine
63+
ports:
64+
- 6379:6379
65+
66+
mongo:
67+
image: mongo:6
68+
ports:
69+
- 27017:27017
70+
volumes:
71+
- mongodb_data_container:/data/db
72+
73+
volumes:
74+
mongodb_data_container:

setup.ps1

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ $ErrorActionPreference = "Stop"
99

1010
# Get current script directory
1111
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition
12-
$COMPOSE_FILE = Join-Path -Path $SCRIPT_DIR -ChildPath "deployment\docker-compose.yaml"
12+
$COMPOSE_FILE_HUB = Join-Path -Path $SCRIPT_DIR -ChildPath "deployment\docker-compose-hub.yaml"
13+
$COMPOSE_FILE_LOCAL = Join-Path -Path $SCRIPT_DIR -ChildPath "deployment\docker-compose.yaml"
14+
$COMPOSE_FILE = $COMPOSE_FILE_HUB
1315
$ENV_FILE = Join-Path -Path $SCRIPT_DIR -ChildPath ".env"
1416

1517
# Function to write colored text
@@ -223,12 +225,15 @@ function Prompt-MainMenu {
223225
Write-Host ""
224226
Write-ColorText "Welcome to DocsGPT Setup!" -ForegroundColor "White" -Bold
225227
Write-ColorText "How would you like to proceed?" -ForegroundColor "White"
226-
Write-ColorText "1) Use DocsGPT Public API Endpoint (simple and free)" -ForegroundColor "Yellow"
228+
Write-ColorText "1) Use DocsGPT Public API Endpoint (simple and free, uses pre-built Docker images from Docker Hub for fastest setup)" -ForegroundColor "Yellow"
227229
Write-ColorText "2) Serve Local (with Ollama)" -ForegroundColor "Yellow"
228230
Write-ColorText "3) Connect Local Inference Engine" -ForegroundColor "Yellow"
229231
Write-ColorText "4) Connect Cloud API Provider" -ForegroundColor "Yellow"
232+
Write-ColorText "5) Advanced: Build images locally (for developers)" -ForegroundColor "Yellow"
230233
Write-Host ""
231-
$script:main_choice = Read-Host "Choose option (1-4)"
234+
Write-ColorText "By default, DocsGPT uses pre-built images from Docker Hub for a fast, reliable, and consistent experience. This avoids local build errors and speeds up onboarding. Advanced users can choose to build images locally if needed." -ForegroundColor "White"
235+
Write-Host ""
236+
$script:main_choice = Read-Host "Choose option (1-5)"
232237
}
233238

234239
# Function to prompt for Local Inference Engine options
@@ -304,9 +309,9 @@ function Use-DocsPublicAPIEndpoint {
304309

305310
# Run Docker compose commands
306311
try {
307-
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" build
312+
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull
308313
if ($LASTEXITCODE -ne 0) {
309-
throw "Docker compose build failed with exit code $LASTEXITCODE"
314+
throw "Docker compose pull failed with exit code $LASTEXITCODE"
310315
}
311316

312317
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d
@@ -415,10 +420,10 @@ function Serve-LocalOllama {
415420
Write-Host ""
416421
Write-ColorText "Starting Docker Compose with Ollama ($docker_compose_file_suffix)..." -ForegroundColor "White"
417422

418-
# Build the containers
419-
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" -f "$optional_compose" build
423+
# Pull the containers
424+
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" -f "$optional_compose" pull
420425
if ($LASTEXITCODE -ne 0) {
421-
throw "Docker compose build failed with exit code $LASTEXITCODE"
426+
throw "Docker compose pull failed with exit code $LASTEXITCODE"
422427
}
423428

424429
# Start the containers
@@ -575,10 +580,10 @@ function Connect-LocalInferenceEngine {
575580
Write-Host ""
576581
Write-ColorText "Starting Docker Compose..." -ForegroundColor "White"
577582

578-
# Build the containers
579-
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" build
583+
# Pull the containers
584+
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull
580585
if ($LASTEXITCODE -ne 0) {
581-
throw "Docker compose build failed with exit code $LASTEXITCODE"
586+
throw "Docker compose pull failed with exit code $LASTEXITCODE"
582587
}
583588

584589
# Start the containers
@@ -706,10 +711,12 @@ function Connect-CloudAPIProvider {
706711
Write-ColorText "Starting Docker Compose..." -ForegroundColor "White"
707712

708713
# Run Docker compose commands
709-
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d --build
714+
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" pull
710715
if ($LASTEXITCODE -ne 0) {
711-
throw "Docker compose build or up failed with exit code $LASTEXITCODE"
716+
throw "Docker compose pull failed with exit code $LASTEXITCODE"
712717
}
718+
719+
& docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d
713720

714721
Write-Host ""
715722
Write-ColorText "DocsGPT is now configured to use $provider_name on http://localhost:5173" -ForegroundColor "Green"
@@ -735,42 +742,46 @@ while ($true) {
735742

736743
switch ($main_choice) {
737744
"1" {
745+
$COMPOSE_FILE = $COMPOSE_FILE_HUB
738746
Use-DocsPublicAPIEndpoint
739747
$exitLoop = $true # Set flag to true on completion
740748
break
741749
}
742750
"2" {
743751
Serve-LocalOllama
744-
# Only exit the loop if user didn't press "b" to go back
745752
if ($ollama_choice -ne "b" -and $ollama_choice -ne "B") {
746753
$exitLoop = $true
747754
}
748755
break
749756
}
750757
"3" {
751758
Connect-LocalInferenceEngine
752-
# Only exit the loop if user didn't press "b" to go back
753759
if ($engine_choice -ne "b" -and $engine_choice -ne "B") {
754760
$exitLoop = $true
755761
}
756762
break
757763
}
758764
"4" {
759765
Connect-CloudAPIProvider
760-
# Only exit the loop if user didn't press "b" to go back
761766
if ($provider_choice -ne "b" -and $provider_choice -ne "B") {
762767
$exitLoop = $true
763768
}
764769
break
765770
}
771+
"5" {
772+
Write-Host ""
773+
Write-ColorText "You have selected to build images locally. This is recommended for developers or if you want to test local changes." -ForegroundColor "Yellow"
774+
$COMPOSE_FILE = $COMPOSE_FILE_LOCAL
775+
Use-DocsPublicAPIEndpoint
776+
$exitLoop = $true
777+
break
778+
}
766779
default {
767780
Write-Host ""
768-
Write-ColorText "Invalid choice. Please choose 1-4." -ForegroundColor "Red"
781+
Write-ColorText "Invalid choice. Please choose 1-5." -ForegroundColor "Red"
769782
Start-Sleep -Seconds 1
770783
}
771784
}
772-
773-
# Only break out of the loop if a function completed successfully
774785
if ($exitLoop) {
775786
break
776787
}

setup.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ NC='\033[0m'
99
BOLD='\033[1m'
1010

1111
# Base Compose file (relative to script location)
12-
COMPOSE_FILE="$(dirname "$(readlink -f "$0")")/deployment/docker-compose.yaml"
12+
COMPOSE_FILE="$(dirname "$(readlink -f "$0")")/deployment/docker-compose-hub.yaml"
13+
COMPOSE_FILE_LOCAL="$(dirname "$(readlink -f "$0")")/deployment/docker-compose.yaml"
1314
ENV_FILE="$(dirname "$(readlink -f "$0")")/.env"
1415

1516
# Animation function
@@ -111,12 +112,15 @@ check_and_start_docker() {
111112
prompt_main_menu() {
112113
echo -e "\n${DEFAULT_FG}${BOLD}Welcome to DocsGPT Setup!${NC}"
113114
echo -e "${DEFAULT_FG}How would you like to proceed?${NC}"
114-
echo -e "${YELLOW}1) Use DocsGPT Public API Endpoint (simple and free)${NC}"
115+
echo -e "${YELLOW}1) Use DocsGPT Public API Endpoint (simple and free, uses pre-built Docker images from Docker Hub for fastest setup)${NC}"
115116
echo -e "${YELLOW}2) Serve Local (with Ollama)${NC}"
116117
echo -e "${YELLOW}3) Connect Local Inference Engine${NC}"
117118
echo -e "${YELLOW}4) Connect Cloud API Provider${NC}"
119+
echo -e "${YELLOW}5) Advanced: Build images locally (for developers)${NC}"
118120
echo
119-
read -p "$(echo -e "${DEFAULT_FG}Choose option (1-4): ${NC}")" main_choice
121+
echo -e "${DEFAULT_FG}By default, DocsGPT uses pre-built images from Docker Hub for a fast, reliable, and consistent experience. This avoids local build errors and speeds up onboarding. Advanced users can choose to build images locally if needed.${NC}"
122+
echo
123+
read -p "$(echo -e "${DEFAULT_FG}Choose option (1-5): ${NC}")" main_choice
120124
}
121125

122126
# Function to prompt for Local Inference Engine options
@@ -176,7 +180,7 @@ use_docs_public_api_endpoint() {
176180
check_and_start_docker
177181

178182
echo -e "\n${NC}Starting Docker Compose...${NC}"
179-
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" build && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d
183+
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d
180184
docker_compose_status=$? # Capture exit status of docker compose
181185

182186
echo "Docker Compose Exit Status: $docker_compose_status"
@@ -252,7 +256,7 @@ serve_local_ollama() {
252256
)
253257

254258
echo -e "\n${NC}Starting Docker Compose with Ollama (${docker_compose_file_suffix})...${NC}"
255-
docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" build
259+
docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" pull
256260
docker compose --env-file "${ENV_FILE}" "${compose_files[@]}" up -d
257261
docker_compose_status=$?
258262

@@ -360,7 +364,7 @@ connect_local_inference_engine() {
360364
check_and_start_docker
361365

362366
echo -e "\n${NC}Starting Docker Compose...${NC}"
363-
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" build && docker compose -f "${COMPOSE_FILE}" up -d
367+
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose -f "${COMPOSE_FILE}" up -d
364368
docker_compose_status=$?
365369

366370
echo "Docker Compose Exit Status: $docker_compose_status" # Debug output
@@ -449,7 +453,7 @@ connect_cloud_api_provider() {
449453
check_and_start_docker
450454

451455
echo -e "\n${NC}Starting Docker Compose...${NC}"
452-
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d --build
456+
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" pull && docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" up -d
453457
docker_compose_status=$?
454458

455459
echo "Docker Compose Exit Status: $docker_compose_status" # Debug output
@@ -468,12 +472,14 @@ connect_cloud_api_provider() {
468472
# Main script execution
469473
animate_dino
470474

475+
471476
while true; do # Main menu loop
472477
clear # Clear screen before showing main menu again
473478
prompt_main_menu
474479

475480
case $main_choice in
476-
1) # Use DocsGPT Public API Endpoint
481+
1) # Use DocsGPT Public API Endpoint (Docker Hub images)
482+
COMPOSE_FILE="$(dirname "$(readlink -f "$0")")/deployment/docker-compose-hub.yaml"
477483
use_docs_public_api_endpoint
478484
break ;;
479485
2) # Serve Local (with Ollama)
@@ -485,8 +491,13 @@ while true; do # Main menu loop
485491
4) # Connect Cloud API Provider
486492
connect_cloud_api_provider
487493
break ;;
494+
5) # Advanced: Build images locally
495+
echo -e "\n${YELLOW}You have selected to build images locally. This is recommended for developers or if you want to test local changes.${NC}"
496+
COMPOSE_FILE="$COMPOSE_FILE_LOCAL"
497+
use_docs_public_api_endpoint
498+
break ;;
488499
*)
489-
echo -e "\n${RED}Invalid choice. Please choose 1-4.${NC}" ; sleep 1 ;;
500+
echo -e "\n${RED}Invalid choice. Please choose 1-5.${NC}" ; sleep 1 ;;
490501
esac
491502
done
492503

0 commit comments

Comments
 (0)