-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
107 lines (78 loc) · 1.97 KB
/
Copy pathsetup.sh
File metadata and controls
107 lines (78 loc) · 1.97 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
print_step() {
echo
echo "==> $1"
}
copy_env_files() {
print_step "Creating .env files"
find . -maxdepth 1 -name "*.example" | while read -r file; do
target="${file%.example}"
if [ ! -f "$target" ]; then
cp "$file" "$target"
echo "Created $target"
else
echo "$target already exists"
fi
done
}
wait_ollama() {
print_step "Waiting for Ollama"
until docker exec ollama ollama list >/dev/null 2>&1; do
sleep 2
done
echo "Ollama is ready."
}
ensure_model() {
local model="$1"
if docker exec ollama ollama list | awk '{print $1}' | grep -Fxq "$model"; then
echo "$model already installed."
else
echo "Downloading $model..."
docker exec ollama ollama pull "$model"
fi
}
install_models() {
print_step "Installing Ollama models"
while IFS= read -r model || [ -n "$model" ]; do
model="$(echo "$model" | xargs)"
[[ -z "$model" ]] && continue
[[ "$model" =~ ^# ]] && continue
ensure_model "$model"
done < models.txt
}
run_alembic() {
print_step "Running Alembic migrations"
docker compose exec web alembic upgrade head
}
check_requirements() {
print_step "Checking Docker"
docker -v >/dev/null 2>&1 || {
echo "Docker is not installed."
exit 1
}
docker compose version >/dev/null 2>&1 || {
echo "Docker Compose is not available."
exit 1
}
}
start_containers() {
print_step "Starting containers"
docker compose up -d --build
}
finish() {
echo
echo "======================================="
echo "Setup completed successfully!"
echo "Frontend : http://localhost:8000"
echo "======================================="
}
check_requirements
copy_env_files
start_containers
wait_ollama
install_models
run_alembic
finish