Skip to content

Commit

Permalink
Merge pull request #97 from iwilltry42/fix/quickstart
Browse files Browse the repository at this point in the history
fix: POSIX compliance for script and make it work with docker compose plugin
  • Loading branch information
sanjay920 committed Feb 24, 2024
2 parents b3a784c + 2182135 commit 7bc6d58
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Rubra is an open-source ChatGPT. It's designed for users who want:
- On MacOS you need to have Xcode Command Line Tools installed: `xcode-select --install`
- At least 16 GB RAM
- At least 10 GB of available disk space
- Docker and Docker Compose installed
- Docker and Docker Compose (>= v2.17.0) installed

### Installation

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ services:
task-executor:
build:
context: ./services/backend/task_executor
additional_contexts:
additional_contexts: # requires compose >=v2.17.0
- core=./core
dockerfile: Dockerfile
image: ghcr.io/rubra-ai/rubra/task_executor:${RUBRA_TAG:-main}
Expand Down
2 changes: 1 addition & 1 deletion embedEtcd.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
listen-client-urls: http://0.0.0.0:2379
advertise-client-urls: http://0.0.0.0:2379
advertise-client-urls: http://0.0.0.0:2379
25 changes: 17 additions & 8 deletions quickstart.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fatal() {
exit 1
}

COMPOSE="docker-compose" # Docker Compose command to use - can be either the traditional docker-compose or the new docker compose (plugin)

# --- report system information ---
report_system_info() {
info "Detecting system information..."
Expand All @@ -24,6 +26,7 @@ report_system_info() {

# For more detailed OS info, you can use /etc/os-release on Linux systems
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
info "OS Name: $NAME"
info "OS Version: $VERSION"
Expand Down Expand Up @@ -98,9 +101,11 @@ check_docker() {
fi
}

# --- check if docker-compose is installed ---
# --- check if docker-compose or docker compose (plugin) is installed ---
check_docker_compose() {
if ! command -v docker-compose >/dev/null 2>&1; then
if command -v docker compose >/dev/null 2>&1; then
COMPOSE="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
fatal "Docker Compose is not installed. Please install Docker Compose before running this script."
fi
}
Expand Down Expand Up @@ -204,7 +209,8 @@ setup_milvus_etcd() {
# --- pull images and start docker containers ---
start_docker_containers() {
info "Pulling images and starting Docker containers"
docker-compose pull && docker-compose up -d || fatal "Failed to start Docker containers"
# shellcheck disable=SC2015
${COMPOSE} pull && ${COMPOSE} up -d || fatal "Failed to start Docker containers"
}

# --- helper function to check if all containers in the rubra network are running ---
Expand All @@ -230,11 +236,12 @@ check_containers_running() {

# --- helper function to wait for all containers to be running ---
wait_for_containers_to_run() {
local retries=5
local wait_seconds=5
local post_wait_seconds=15 # Additional wait time after containers are confirmed running
retries=5
wait_seconds=5
post_wait_seconds=15 # Additional wait time after containers are confirmed running

for ((i=0; i<retries; i++)); do
i=0
while [ "$i" -lt "$retries" ]; do
if check_containers_running; then
info "All containers are running. Waiting an additional $post_wait_seconds seconds before proceeding to allow for Rubra backend to load."
sleep "$post_wait_seconds"
Expand All @@ -243,11 +250,13 @@ wait_for_containers_to_run() {
warn "Not all containers are running. Waiting for $wait_seconds seconds before retrying..."
sleep "$wait_seconds"
fi
i=$((i + 1))
done

fatal "Not all containers are running after $retries retries."
}


# --- stop docker containers and rubra.llamafile ---
stop_rubra() {
RUBRA_DIR="$HOME/.rubra"
Expand All @@ -268,7 +277,7 @@ stop_rubra() {

if [ -f docker-compose.yml ]; then
info "Stopping Docker containers"
docker-compose down || warn "Failed to stop Docker containers."
${COMPOSE} down || warn "Failed to stop Docker containers."
else
warn "docker-compose.yml not found. Cannot stop Docker containers."
fi
Expand Down

0 comments on commit 7bc6d58

Please sign in to comment.