-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·156 lines (137 loc) · 3.78 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·156 lines (137 loc) · 3.78 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
#!/bin/bash
# Development script for JIRA Clone
# This script manages the development environment with hot reloading
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
print_status() {
echo -e "${BLUE}[DEV]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to start development environment
start_dev() {
print_status "Starting development environment with hot reloading..."
# Stop production containers if running
if docker compose ps | grep -q "jira-clone"; then
print_warning "Stopping production containers..."
docker compose down
fi
# Start development environment
docker compose -f docker-compose.dev.yml up -d
print_success "Development environment started!"
print_status "Frontend: http://localhost:3000 (with hot reload)"
print_status "Backend: http://localhost:8080 (with auto-restart)"
print_status "Database: localhost:5432"
print_status ""
print_status "To view logs: ./dev.sh logs"
print_status "To stop: ./dev.sh stop"
}
# Function to stop development environment
stop_dev() {
print_status "Stopping development environment..."
docker compose -f docker-compose.dev.yml down
print_success "Development environment stopped!"
}
# Function to show logs
show_logs() {
if [ -z "$2" ]; then
print_status "Showing logs for all services..."
docker compose -f docker-compose.dev.yml logs -f
else
print_status "Showing logs for $2..."
docker compose -f docker-compose.dev.yml logs -f "$2"
fi
}
# Function to restart a service
restart_service() {
if [ -z "$2" ]; then
print_error "Please specify a service to restart (frontend, backend, database)"
exit 1
fi
print_status "Restarting $2..."
docker compose -f docker-compose.dev.yml restart "$2"
print_success "$2 restarted!"
}
# Function to show status
show_status() {
print_status "Development environment status:"
docker compose -f docker-compose.dev.yml ps
}
# Function to clean up
cleanup() {
print_status "Cleaning up development environment..."
docker compose -f docker-compose.dev.yml down -v
docker volume prune -f
print_success "Cleanup complete!"
}
# Function to show help
show_help() {
echo "JIRA Clone Development Script"
echo ""
echo "Usage: ./dev.sh [command]"
echo ""
echo "Commands:"
echo " start Start development environment with hot reloading"
echo " stop Stop development environment"
echo " restart Restart development environment"
echo " logs Show logs for all services"
echo " logs [service] Show logs for specific service (frontend, backend, database)"
echo " status Show status of development services"
echo " clean Clean up development environment and volumes"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " ./dev.sh start"
echo " ./dev.sh logs frontend"
echo " ./dev.sh restart backend"
}
# Main script logic
case "$1" in
start)
start_dev
;;
stop)
stop_dev
;;
restart)
if [ -z "$2" ]; then
stop_dev
start_dev
else
restart_service "$1" "$2"
fi
;;
logs)
show_logs "$@"
;;
status)
show_status
;;
clean)
cleanup
;;
help|--help|-h)
show_help
;;
*)
if [ -z "$1" ]; then
show_help
else
print_error "Unknown command: $1"
show_help
exit 1
fi
;;
esac