-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·124 lines (115 loc) · 4.56 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·124 lines (115 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
#
# OmicsBase single-command POC setup.
#
# Prerequisite: Docker (with the Compose plugin). Nothing else.
# git clone <repo> omicsbase && cd omicsbase
# ./run.sh # configure, pull, start, print URLs
# ./run.sh down # stop (data is kept in ./data)
#
set -euo pipefail
COMPOSE_FILE="docker-compose.poc.yml"
DATA_DIR="data"
ENV_FILE=".env"
FRONTEND_URL="http://localhost:3000"
API_URL="http://localhost:8000"
say() { printf '\033[1;36m%s\033[0m\n' "$*"; }
warn() { printf '\033[1;33m%s\033[0m\n' "$*"; }
die() { printf '\033[1;31m%s\033[0m\n' "$*" >&2; exit 1; }
if [ "${1:-}" = "down" ]; then
say "Stopping OmicsBase..."
docker compose -f "$COMPOSE_FILE" down
say "Stopped. Your data is preserved in ./$DATA_DIR."
exit 0
fi
if [ "${1:-}" != "" ]; then
die "Unknown argument '$1'. Usage: ./run.sh | ./run.sh down"
fi
# --- 1. Prerequisites -------------------------------------------------------
if [ "$(id -u)" = "0" ]; then
die "Do not run this script as root."
fi
if ! command -v docker >/dev/null 2>&1; then
die "Docker is not installed.
Linux: sudo apt install docker.io docker-compose-v2 (or Docker Engine per your distro)
macOS: install Docker Desktop from https://www.docker.com/products/docker-desktop/
Windows: install Docker Desktop, then run this script inside WSL2."
fi
if ! docker compose version >/dev/null 2>&1; then
die "Docker is installed but the Compose plugin is missing.
Linux: sudo apt install docker-compose-v2 (or 'docker compose' from your distro)
Other: Docker Desktop includes Compose."
fi
if ! docker info >/dev/null 2>&1; then
die "Docker is installed but not accessible from this shell.
If your user is not in the docker group yet: sudo usermod -aG docker \$USER
then log out and back in. Alternatively run: sg docker -c './run.sh'"
fi
# --- 2. Data directories (owned by the current user, no sudo) ---------------
mkdir -p "$DATA_DIR/projects" "$DATA_DIR/knowledge"
if [ ! -f "$DATA_DIR/knowledge/bioc_books.yaml" ] && [ -f "backend/knowledge/bioc_books.yaml" ]; then
cp -r backend/knowledge/. "$DATA_DIR/knowledge/"
say "Seeded knowledge catalog into ./$DATA_DIR/knowledge."
fi
# --- 3. Configuration -------------------------------------------------------
if [ ! -f "$ENV_FILE" ]; then
say "First run: let's configure your LLM provider."
printf 'LLM provider [anthropic|openai|gemini|groq|openrouter|ollama] (default: anthropic): '
read -r PROVIDER
PROVIDER="${PROVIDER:-anthropic}"
case "$PROVIDER" in
ollama)
API_KEY="not-needed"
;;
*)
if [ -n "${ANTHROPIC_API_KEY:-}" ] || [ -n "${OPENAI_API_KEY:-}" ] || [ -n "${GEMINI_API_KEY:-}" ] || [ -n "${GROQ_API_KEY:-}" ] || [ -n "${OPENROUTER_API_KEY:-}" ]; then
warn "An LLM API key is already exported in this shell; reusing it."
fi
printf 'Paste your %s API key (input is hidden): ' "$PROVIDER"
read -rs API_KEY
printf '\n'
if [ -z "$API_KEY" ]; then
die "No API key provided. OmicsBase needs an LLM API key to run."
fi
;;
esac
case "$PROVIDER" in
anthropic) KEY_LINE="ANTHROPIC_API_KEY=$API_KEY" ;;
openai) KEY_LINE="OPENAI_API_KEY=$API_KEY" ;;
gemini) KEY_LINE="GEMINI_API_KEY=$API_KEY" ;;
groq) KEY_LINE="GROQ_API_KEY=$API_KEY" ;;
openrouter) KEY_LINE="OPENROUTER_API_KEY=$API_KEY" ;;
ollama) KEY_LINE="OLLAMA_API_KEY=$API_KEY" ;;
*) die "Unsupported provider '$PROVIDER'." ;;
esac
cat > "$ENV_FILE" <<EOF
# Generated by ./run.sh
LLM_PROVIDER=$PROVIDER
$KEY_LINE
DATABASE_URL=postgresql://omicsbase:omicsbase@localhost:5433/omicsbase
REDIS_URL=redis://localhost:6379/0
TASK_BACKEND=celery
PROJECTS_DIR=./projects
DEV_MODE=true
USE_DOCKER_SANDBOX=false
EOF
say "Configuration written to $ENV_FILE."
else
say "Using existing $ENV_FILE (remove it to reconfigure)."
fi
# --- 4. Pull and start ------------------------------------------------------
say "Pulling OmicsBase images (first run may take a few minutes)..."
docker compose -f "$COMPOSE_FILE" pull
say "Starting OmicsBase..."
docker compose -f "$COMPOSE_FILE" up -d --wait || {
warn "Some services did not become healthy. Showing logs:"
docker compose -f "$COMPOSE_FILE" logs --tail=40 backend frontend
die "Startup failed. Run './run.sh down' and try again, or open an issue with the logs above."
}
say ""
say "OmicsBase is running!"
say " Frontend: $FRONTEND_URL"
say " API docs: $API_URL/docs"
say ""
say "Try: New note -> attach a CSV -> ask the agent about your data."
warn "Keep this machine running while you work; stop anytime with: ./run.sh down"