-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
Β·178 lines (157 loc) Β· 5.09 KB
/
dev.sh
File metadata and controls
executable file
Β·178 lines (157 loc) Β· 5.09 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
#!/bin/bash
# BioAnalyzer Development Script
# This script sets up the development environment with hot reloading
echo "π BioAnalyzer Development Environment"
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "β Docker is not running. Please start Docker first."
exit 1
fi
# Create necessary directories
mkdir -p data cache results logs
# Check if .env file exists
if [ ! -f .env ]; then
echo "β οΈ .env file not found. Creating a template..."
cat > .env << EOF
# BioAnalyzer Environment Variables
NCBI_API_KEY=your_ncbi_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
DEBUG=true
ENVIRONMENT=development
EOF
echo "π Please edit .env file with your API keys"
fi
# Function to start development environment with build
start_dev_build() {
echo "π§ Starting development environment with build..."
# Stop any existing containers
docker compose -f docker-compose.dev.yml down
# Build and start development environment
docker compose -f docker-compose.dev.yml up -d --build
echo "β³ Waiting for services to start..."
sleep 10
check_services
}
# Function to start development environment without build
start_dev_no_build() {
echo "π Starting development environment (no build)..."
# Just start services (assumes they're already built)
docker compose -f docker-compose.dev.yml up -d
echo "β³ Waiting for services to start..."
sleep 5
check_services
}
# Function to check service health
check_services() {
if docker compose -f docker-compose.dev.yml ps | grep -q "healthy"; then
echo "β
Development environment is ready!"
echo "π Frontend: http://localhost"
echo "π Backend API: http://localhost:8000"
echo "π API Docs: http://localhost:8000/docs"
echo ""
echo "π‘ Hot reloading is enabled:"
echo " - Backend changes will auto-restart the server"
echo " - Frontend changes will be reflected immediately"
echo " - Just refresh your browser to see changes!"
echo ""
echo "π To stop: ./dev.sh stop"
echo "π To view logs: ./dev.sh logs"
echo "π To restart: ./dev.sh restart"
else
echo "β Some services failed to start. Check logs:"
docker compose -f docker-compose.dev.yml logs
fi
}
# Function to stop development environment
stop_dev() {
echo "π Stopping development environment..."
docker compose -f docker-compose.dev.yml down
echo "β
Development environment stopped"
}
# Function to show logs
show_logs() {
echo "π Showing logs..."
docker compose -f docker-compose.dev.yml logs -f
}
# Function to restart services
restart_dev() {
echo "π Restarting services..."
docker compose -f docker-compose.dev.yml restart
echo "β
Services restarted"
}
# Function to show status
show_status() {
echo "π Service Status:"
docker compose -f docker-compose.dev.yml ps
}
# Main script logic
case "${1:-start}" in
start)
echo ""
echo "Choose startup option:"
echo "1) Start with build (first time or after dependency changes)"
echo "2) Start without build (daily development - faster)"
echo "3) Exit"
echo ""
read -p "Enter choice (1-3): " choice
case $choice in
1)
start_dev_build
;;
2)
start_dev_no_build
;;
3)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice. Starting with build..."
start_dev_build
;;
esac
;;
start-build)
start_dev_build
;;
start-no-build)
start_dev_no_build
;;
stop)
stop_dev
;;
restart)
restart_dev
;;
logs)
show_logs
;;
status)
show_status
;;
*)
echo "Usage: $0 {start|start-build|start-no-build|stop|restart|logs|status}"
echo ""
echo "Commands:"
echo " start - Interactive startup (asks if you want to build)"
echo " start-build - Start with build (first time or dependencies changed)"
echo " start-no-build- Start without build (daily development - faster)"
echo " stop - Stop development environment"
echo " restart - Restart services"
echo " logs - Show live logs"
echo " status - Show service status"
echo ""
echo "Examples:"
echo " ./dev.sh # Interactive startup"
echo " ./dev.sh start-build # Start with build"
echo " ./dev.sh start-no-build # Start without build (fastest)"
echo " ./dev.sh logs # Show logs"
echo ""
echo "π‘ Daily Development Workflow:"
echo " 1. First time: ./dev.sh start-build"
echo " 2. Daily use: ./dev.sh start-no-build"
echo " 3. Make code changes - they auto-reload!"
echo " 4. Stop when done: ./dev.sh stop"
exit 1
;;
esac