-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
178 lines (141 loc) · 4.24 KB
/
Makefile
File metadata and controls
178 lines (141 loc) · 4.24 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
# ================================
# ProWidget Makefile
# Convenience commands for development
# ================================
.PHONY: help install dev build start stop restart logs clean db-reset db-migrate db-seed
# Default target
help:
@echo "ProWidget - Available Commands"
@echo "=================================="
@echo ""
@echo "Setup:"
@echo " make install - Install all dependencies"
@echo " make setup - Full setup (install + db migrate)"
@echo ""
@echo "Development:"
@echo " make dev - Start development environment"
@echo " make dev-docker - Start with Docker (dev mode)"
@echo ""
@echo "Production:"
@echo " make build - Build all services"
@echo " make start - Start production containers"
@echo " make stop - Stop all containers"
@echo " make restart - Restart all containers"
@echo ""
@echo "Database:"
@echo " make db-migrate - Run database migrations"
@echo " make db-reset - Reset database (WARNING: deletes data)"
@echo " make db-seed - Seed database with sample data"
@echo ""
@echo "Utilities:"
@echo " make logs - View container logs"
@echo " make clean - Remove containers and volumes"
@echo " make shell-backend - Open shell in backend container"
@echo ""
# ================================
# Setup
# ================================
install:
@echo "Installing dependencies..."
cd backend && npm install
cd admin-panel && npm install
cd xml-parser && npm install
cd cdn && npm install
@echo "Dependencies installed!"
setup: install db-migrate
@echo "Setup complete!"
# ================================
# Development
# ================================
dev:
@echo "Starting development servers..."
@echo "Backend: http://localhost:3000"
@echo "Admin: http://localhost:3001"
@make -j3 dev-backend dev-admin dev-xml-parser
dev-backend:
cd backend && npm run dev
dev-admin:
cd admin-panel && npm run dev
dev-xml-parser:
cd xml-parser && npm run dev
dev-docker:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build
# ================================
# Production
# ================================
build:
@echo "Building Docker images..."
docker-compose build
start:
@echo "Starting production containers..."
docker-compose up -d
@echo ""
@echo "Services started:"
@echo " Backend API: http://localhost:3000"
@echo " Admin Panel: http://localhost:3001"
@echo ""
stop:
@echo "Stopping containers..."
docker-compose down
restart: stop start
# ================================
# Database
# ================================
db-migrate:
@echo "Running database migrations..."
cd backend && npx prisma migrate deploy
db-reset:
@echo "WARNING: This will delete all data!"
@read -p "Are you sure? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
cd backend && npx prisma migrate reset --force
db-seed:
@echo "Seeding database..."
cd backend && npx prisma db seed
db-studio:
@echo "Opening Prisma Studio..."
cd backend && npx prisma studio
# ================================
# Utilities
# ================================
logs:
docker-compose logs -f
logs-backend:
docker-compose logs -f backend
logs-admin:
docker-compose logs -f admin
logs-parser:
docker-compose logs -f xml-parser
clean:
@echo "Cleaning up..."
docker-compose down -v --remove-orphans
docker system prune -f
@echo "Cleanup complete!"
shell-backend:
docker-compose exec backend sh
shell-db:
docker-compose exec db psql -U $${POSTGRES_USER:-pwx_user} -d $${POSTGRES_DB:-prowidget}
# ================================
# Testing
# ================================
test:
@echo "Running tests..."
cd backend && npm test
cd admin-panel && npm test
test-backend:
cd backend && npm test
test-admin:
cd admin-panel && npm test
# ================================
# CDN Build
# ================================
build-cdn:
@echo "Building CDN scripts..."
cd cdn && npm run build
@echo "CDN build complete! Output in cdn/dist/"
# ================================
# Health Check
# ================================
health:
@echo "Checking service health..."
@curl -s http://localhost:3000/api/health | jq . || echo "Backend: Not responding"
@curl -s http://localhost:3001 > /dev/null && echo "Admin: OK" || echo "Admin: Not responding"