-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·191 lines (175 loc) · 7.64 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·191 lines (175 loc) · 7.64 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
#!/bin/bash
# ============================================================
# GrandFlow - DEV MODE
# Infrastructure only: PostgreSQL, Redis, API Gateway, Nginx
# Frontend and Backend services run on local machine
# ============================================================
set -e
# Relative paths below (compose file, env file) must resolve against the
# repo root regardless of the caller's cwd — .devrc aliases this script by
# absolute path, so `cd`ing to wherever the shell happens to be otherwise
# breaks (e.g. running dev-infra-down from inside services/chat).
cd "$(dirname "${BASH_SOURCE[0]:-$0}")"
MODE="$1"
COMPOSE_FILE="docker-compose.dev.yml"
ENV_FILE=".env.dev"
COMPOSE="docker compose -f $COMPOSE_FILE --env-file $ENV_FILE"
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_header() {
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}========================================${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_info() {
echo -e "${YELLOW}→ $1${NC}"
}
case "$MODE" in
up)
print_header "Starting DEV MODE"
print_info "Starting infrastructure (DB, Redis, Nginx)..."
systemctl stop postgresql redis 2>/dev/null || true
DOCKER_BUILDKIT=1 $COMPOSE up -d --build
print_success "Infrastructure started!"
echo ""
echo -e "${GREEN}DEV MODE is ready!${NC}"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Start Users Service locally (port 8000):"
echo " cd services/users && alembic upgrade head && python -m uvicorn main:app --reload --port 8000"
echo ""
echo "2. Start Budget Service locally (port 8001) - in another terminal:"
echo " cd services/budget && alembic upgrade head && python -m uvicorn main:app --reload --port 8001"
echo ""
echo "3. Start AI Service locally (port 8002) - in another terminal:"
echo " cd services/ai && alembic upgrade head && python -m uvicorn main:app --reload --port 8002"
echo ""
echo "4. Start Chat Service locally (port 8003) - in another terminal:"
echo " cd services/chat && alembic upgrade head && python -m uvicorn main:app --reload --port 8003"
echo ""
echo "5. Start Frontend locally - in another terminal:"
echo " cd frontend-typescript && npm run dev"
echo ""
echo "Or run: ./dev.sh services (for detailed commands)"
echo ""
echo -e "${YELLOW}Available endpoints:${NC}"
echo " Database: localhost:5432"
echo " Redis: localhost:6379"
echo " RabbitMQ: localhost:5672 (AMQP), localhost:15672 (UI)"
echo " MinIO (S3 API): localhost:9000"
echo " MinIO Console: http://localhost:9001 (minioadmin:minioadmin)"
echo " Flower (Celery UI): http://localhost:5555"
echo " Nginx Proxy: localhost:8082"
echo " Users Service: localhost:8000 (run locally) - http://localhost:8000/docs"
echo " Budget Service: localhost:8001 (run locally) - http://localhost:8001/docs"
echo " AI Service: localhost:8002 (run locally) - http://localhost:8002/docs"
echo " Chat Service: localhost:8003 (run locally) - http://localhost:8003/docs"
echo " Frontend: localhost:3000 (run locally)"
echo " Celery Worker: run locally (see ./dev.sh services)"
echo " Celery Beat: run locally (see ./dev.sh services)"
echo ""
echo -e "${YELLOW}Monitoring & Observability:${NC}"
echo " Jaeger Tracing: http://localhost:16686"
echo " Prometheus Metrics: http://localhost:9090"
echo " Grafana Dashboards: http://localhost:3002 (admin:admin)"
echo " Users Metrics: http://localhost:8000/metrics"
echo " Budget Metrics: http://localhost:8001/metrics"
echo " AI Metrics: http://localhost:8002/metrics"
echo " Chat Metrics: http://localhost:8003/metrics"
;;
down)
print_header "Stopping DEV MODE"
$COMPOSE down
print_success "DEV MODE stopped"
;;
logs)
$COMPOSE logs -f
;;
status)
print_header "DEV MODE Status"
$COMPOSE ps
;;
rebuild)
print_header "Rebuilding DEV MODE containers"
DOCKER_BUILDKIT=1 $COMPOSE build --no-cache
print_success "Containers rebuilt"
;;
services)
print_header "Running Services Locally - Commands"
echo ""
echo -e "${YELLOW}Open new terminals and run these commands:${NC}"
echo ""
echo -e "${BLUE}=== Terminal 1: Users Service (port 8000) ===${NC}"
echo "cd services/users"
echo "alembic upgrade head"
echo "python -m uvicorn main:app --reload --port 8000"
echo ""
echo -e "${BLUE}=== Terminal 2: Budget Service (port 8001) ===${NC}"
echo "cd services/budget"
echo "alembic upgrade head"
echo "python -m uvicorn main:app --reload --port 8001"
echo ""
echo -e "${BLUE}=== Terminal 3: AI Service (port 8002) ===${NC}"
echo "cd services/ai"
echo "alembic upgrade head"
echo "python -m uvicorn main:app --reload --port 8002"
echo ""
echo -e "${BLUE}=== Terminal 4: Chat Service (port 8003) ===${NC}"
echo "cd services/chat"
echo "alembic upgrade head"
echo "python -m uvicorn main:app --reload --port 8003"
echo ""
echo -e "${BLUE}=== Terminal 5: Frontend ===${NC}"
echo "cd frontend-typescript"
echo "npm install # first time only"
echo "npm run dev"
echo ""
echo -e "${BLUE}=== Terminal 6: Celery Worker ===${NC}"
echo "cd services/worker"
echo "celery -A celery_app worker --loglevel=info -Q ai,budget,users,feedback"
echo ""
echo -e "${BLUE}=== Terminal 7: Celery Beat ===${NC}"
echo "cd services/worker"
echo "celery -A celery_app beat --loglevel=info"
echo ""
echo -e "${YELLOW}Endpoints:${NC}"
echo " Frontend: http://localhost:3000"
echo " Users API: http://localhost:8000/docs"
echo " Budget API: http://localhost:8001/docs"
echo " AI API: http://localhost:8002/docs"
echo " Chat API: http://localhost:8003/docs"
echo " Nginx Proxy: http://localhost:8082"
echo ""
echo -e "${YELLOW}Monitoring (already running in Docker):${NC}"
echo " Jaeger: http://localhost:16686 (traces)"
echo " Prometheus: http://localhost:9090 (metrics)"
echo " Grafana: http://localhost:3001 (dashboards, admin:admin)"
echo " Flower: http://localhost:5555 (Celery task monitor)"
echo ""
echo -e "${YELLOW}Note: .env.*.dev files already have localhost configured${NC}"
;;
clean)
print_header "Cleaning up DEV MODE"
$COMPOSE down -v
print_success "DEV MODE cleaned (volumes removed)"
;;
*)
echo "Usage: ./dev.sh {up|down|logs|status|rebuild|services|clean}"
echo ""
echo "Commands:"
echo " up - Start infrastructure for dev mode"
echo " down - Stop infrastructure"
echo " logs - View logs"
echo " status - Show container status"
echo " rebuild - Rebuild containers without cache"
echo " services - Show commands to run services locally"
echo " clean - Stop and remove volumes"
exit 1
;;
esac