-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·200 lines (176 loc) · 4.68 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·200 lines (176 loc) · 4.68 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
#!/bin/bash
# Eazzy Backend Development Script
# Usage: ./dev.sh [command]
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
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${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 check if Docker is running
check_docker() {
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running. Please start Docker first."
exit 1
fi
}
# Function to start development environment
start_dev() {
print_status "Starting development environment..."
check_docker
# Stop any existing containers
docker-compose down 2>/dev/null || true
# Start with override file (development mode)
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
print_success "Development environment started!"
print_status "App: http://localhost:8002"
print_status "Database: localhost:5432"
print_status "Redis: localhost:6379"
print_status ""
print_status "File changes are automatically reflected in the container."
print_status "Use 'docker-compose logs -f app' to see logs."
}
# Function to stop development environment
stop_dev() {
print_status "Stopping development environment..."
docker-compose down
print_success "Development environment stopped!"
}
# Function to restart development environment
restart_dev() {
print_status "Restarting development environment..."
stop_dev
start_dev
}
# Function to show logs
logs() {
print_status "Showing application logs..."
docker-compose logs -f app
}
# Function to run commands in container
exec_container() {
print_status "Executing command in container..."
docker-compose exec app "$@"
}
# Function to install dependencies
install_deps() {
print_status "Installing dependencies..."
docker-compose exec app composer install
print_success "Dependencies installed!"
}
# Function to run migrations
migrate() {
print_status "Running migrations..."
docker-compose exec app php artisan migrate --force
print_success "Migrations completed!"
}
# Function to force remigration with seeding
remigrate_fresh() {
print_status "Force refreshing database with migrations and seeding..."
docker-compose exec app php artisan migrate:fresh --seed --force
print_success "Database refreshed and seeded!"
}
# Function to clear caches
clear_cache() {
print_status "Clearing caches..."
docker-compose exec app php artisan config:clear
docker-compose exec app php artisan cache:clear
docker-compose exec app php artisan route:clear
docker-compose exec app php artisan view:clear
print_success "Caches cleared!"
}
# Function to run tests
test() {
print_status "Running tests..."
docker-compose exec app php artisan test
}
# Function to show status
status() {
print_status "Development environment status:"
docker-compose ps
}
# Function to show help
show_help() {
echo "Eazzy Backend Development Script"
echo ""
echo "Usage: ./dev.sh [command]"
echo ""
echo "Commands:"
echo " start Start development environment"
echo " stop Stop development environment"
echo " restart Restart development environment"
echo " logs Show application logs"
echo " exec Execute command in container (e.g., ./dev.sh exec bash)"
echo " install Install dependencies"
echo " migrate Run database migrations"
echo " remigrate Force refresh database with migrations and seeding"
echo " clear Clear all caches"
echo " test Run tests"
echo " status Show container status"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " ./dev.sh start"
echo " ./dev.sh exec bash"
echo " ./dev.sh exec php artisan tinker"
echo " ./dev.sh logs"
}
# Main script logic
case "${1:-start}" in
start)
start_dev
;;
stop)
stop_dev
;;
restart)
restart_dev
;;
logs)
logs
;;
exec)
shift
exec_container "$@"
;;
install)
install_deps
;;
migrate)
migrate
;;
remigrate)
remigrate_fresh
;;
clear)
clear_cache
;;
test)
test
;;
status)
status
;;
help|--help|-h)
show_help
;;
*)
print_error "Unknown command: $1"
show_help
exit 1
;;
esac