forked from Traqora/astroml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-start.sh
More file actions
278 lines (250 loc) · 7.07 KB
/
Copy pathdocker-start.sh
File metadata and controls
278 lines (250 loc) · 7.07 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/bash
# Docker Start Script for AstroML
# This script provides easy commands to start various AstroML Docker services
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if Docker is running
check_docker() {
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running. Please start Docker and try again."
exit 1
fi
print_status "Docker is running"
}
# Function to start core services
start_core() {
print_status "Starting core services (PostgreSQL, Redis)..."
docker-compose up -d postgres redis
print_status "Core services started"
}
# Function to start ingestion services
start_ingestion() {
print_status "Starting ingestion services..."
docker-compose up -d ingestion streaming
print_status "Ingestion services started"
}
# Function to start development environment
start_dev() {
print_status "Starting development environment..."
docker-compose --profile dev up -d
print_status "Development environment started"
print_status "Jupyter Lab available at http://localhost:8888"
}
# Function to start training (CPU)
start_training_cpu() {
print_status "Starting CPU training service..."
docker-compose --profile cpu up -d training-cpu
print_status "CPU training service started"
}
# Function to start training (GPU)
start_training_gpu() {
print_status "Starting GPU training service..."
docker-compose --profile gpu up -d training-gpu
print_status "GPU training service started"
print_status "TensorBoard available at http://localhost:6006"
}
# Function to start Soroban development
start_soroban() {
print_status "Starting Soroban development environment..."
docker-compose --profile soroban up -d soroban-dev
print_status "Soroban development environment started"
}
# Function to start monitoring
start_monitoring() {
print_status "Starting monitoring stack..."
docker-compose --profile monitoring up -d
print_status "Monitoring stack started"
print_status "Prometheus available at http://localhost:9090"
print_status "Grafana available at http://localhost:3000 (admin/admin)"
}
# Function to start production
start_production() {
print_status "Starting production services..."
docker-compose --profile prod up -d
print_status "Production services started"
}
# Function to start all services
start_all() {
print_status "Starting all services..."
docker-compose up -d
print_status "All services started"
}
# Function to stop services
stop_services() {
print_status "Stopping services..."
docker-compose down
print_status "Services stopped"
}
# Function to stop all services including volumes
stop_all() {
print_status "Stopping all services and removing volumes..."
docker-compose down -v
print_status "All services stopped and volumes removed"
}
# Function to show status
show_status() {
print_status "Service status:"
docker-compose ps
}
# Function to show logs
show_logs() {
if [ -z "$1" ]; then
docker-compose logs -f
else
docker-compose logs -f "$1"
fi
}
# Function to rebuild services
rebuild() {
if [ -z "$1" ]; then
print_status "Rebuilding all services..."
docker-compose build --no-cache
else
print_status "Rebuilding service: $1..."
docker-compose build --no-cache "$1"
fi
}
# Function to run tests
run_tests() {
print_status "Running tests..."
docker-compose run --rm dev pytest tests/ -v
}
# Function to run Soroban tests
run_soroban_tests() {
print_status "Running Soroban contract tests..."
docker-compose --profile soroban-test run soroban-test
}
# Function to build Soroban contracts
build_soroban() {
print_status "Building Soroban contracts..."
docker-compose --profile soroban-build run soroban-build
}
# Function to clean up
cleanup() {
print_status "Cleaning up Docker resources..."
docker system prune -f
print_status "Cleanup completed"
}
# Function to show help
show_help() {
echo "AstroML Docker Management Script"
echo ""
echo "Usage: ./docker-start.sh [command]"
echo ""
echo "Commands:"
echo " core Start core services (PostgreSQL, Redis)"
echo " ingestion Start ingestion services"
echo " dev Start development environment"
echo " training-cpu Start CPU training service"
echo " training-gpu Start GPU training service"
echo " soroban Start Soroban development environment"
echo " monitoring Start monitoring stack (Prometheus, Grafana)"
echo " production Start production services"
echo " all Start all services"
echo " stop Stop services"
echo " stop-all Stop all services and remove volumes"
echo " status Show service status"
echo " logs [service] Show logs (all services or specific service)"
echo " rebuild [service] Rebuild services"
echo " test Run tests"
echo " soroban-test Run Soroban contract tests"
echo " soroban-build Build Soroban contracts"
echo " cleanup Clean up Docker resources"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " ./docker-start.sh core"
echo " ./docker-start.sh dev"
echo " ./docker-start.sh logs ingestion"
echo " ./docker-start.sh rebuild ingestion"
}
# Main script logic
main() {
check_docker
case "${1:-help}" in
core)
start_core
;;
ingestion)
start_core
start_ingestion
;;
dev)
start_core
start_dev
;;
training-cpu)
start_core
start_training_cpu
;;
training-gpu)
start_core
start_training_gpu
;;
soroban)
start_soroban
;;
monitoring)
start_core
start_monitoring
;;
production)
start_core
start_production
;;
all)
start_all
;;
stop)
stop_services
;;
stop-all)
stop_all
;;
status)
show_status
;;
logs)
show_logs "$2"
;;
rebuild)
rebuild "$2"
;;
test)
run_tests
;;
soroban-test)
run_soroban_tests
;;
soroban-build)
build_soroban
;;
cleanup)
cleanup
;;
help|--help|-h)
show_help
;;
*)
print_error "Unknown command: $1"
show_help
exit 1
;;
esac
}
# Run main function
main "$@"