11# apprun Makefile
22
3- .PHONY : help build test test-all test-unit test-integration test-e2e clean docker-build docker-up docker-down validate-stories sync-index
3+ .PHONY : help build test test-all test-unit test-integration test-e2e clean docker-build docker-up docker-down validate-stories sync-index dev-up dev-down run-local build-local test-local prod-up-local prod-down-local
44
55# 默认目标
66help :
77 @echo " Available targets:"
8+ @echo " "
9+ @echo " Build & Test:"
810 @echo " build - Build the application"
911 @echo " test-all - Run all tests"
1012 @echo " test-unit - Run unit tests"
11- @echo " test-unit-html - Run unit tests with HTML coverage report"
12- @echo " test-unit-setup- Setup unit test environment"
13- @echo " test-unit-run - Run unit tests via script"
1413 @echo " test-integration - Run integration tests"
1514 @echo " test-e2e - Run end-to-end tests"
15+ @echo " "
16+ @echo " Development Environment (Story 1):"
17+ @echo " dev-up - Start dev dependencies (postgres + redis)"
18+ @echo " dev-down - Stop dev dependencies"
19+ @echo " run-local - Run app locally with go run"
20+ @echo " build-local - Build Docker image locally"
21+ @echo " test-local - Run integration tests with local image"
22+ @echo " prod-up-local - Start production-like environment locally"
23+ @echo " prod-down-local- Stop local production environment"
24+ @echo " "
25+ @echo " Docker:"
1626 @echo " docker-build - Build Docker images"
1727 @echo " docker-up - Start Docker services"
1828 @echo " docker-down - Stop Docker services"
29+ @echo " "
30+ @echo " Documentation:"
1931 @echo " validate-stories - Validate all Story documents"
2032 @echo " sync-index - Sync global Stories index"
33+ @echo " "
2134 @echo " clean - Clean build artifacts"
2235
2336# 构建
@@ -62,10 +75,10 @@ docker-build:
6275 cd docker && docker compose build
6376
6477docker-up :
65- cd docker && docker compose up -d
78+ docker compose up -d
6679
6780docker-down :
68- cd docker && docker compose down
81+ docker compose down
6982
7083# 清理
7184clean :
@@ -100,4 +113,80 @@ validate-stories:
100113sync-index :
101114 @echo " 🔄 Syncing global Stories index..."
102115 @./scripts/sync-story-index.sh
103- @echo " ✅ Global Stories index synced"
116+ @echo " ✅ Global Stories index synced"
117+
118+ # ============================================
119+ # Story 1: Development Environment Commands
120+ # ============================================
121+
122+ # Start development dependencies only (postgres + redis)
123+ dev-up :
124+ @echo " 🚀 Starting development dependencies..."
125+ @docker compose -f docker-compose.dev.yml up -d
126+ @echo " ✅ Development dependencies ready!"
127+ @echo " "
128+ @echo " 📊 Services:"
129+ @echo " PostgreSQL: localhost:5432 (user: apprun, password: dev_password_123)"
130+ @echo " Redis: localhost:6379"
131+ @echo " "
132+ @echo " 💡 Next step: Run your app locally"
133+ @echo " go run core/cmd/server/main.go"
134+
135+ # Stop development dependencies
136+ dev-down :
137+ @echo " 🛑 Stopping development dependencies..."
138+ @docker compose -f docker-compose.dev.yml down
139+ @echo " ✅ Development dependencies stopped"
140+
141+ # Run app locally (assumes dev-up is running)
142+ run-local :
143+ @echo " 🏃 Running app locally..."
144+ @echo " 📌 Make sure dependencies are running: make dev-up"
145+ @echo " "
146+ cd core && go run ./cmd/server/main.go
147+
148+ # Build Docker image locally
149+ build-local :
150+ @echo " 🔨 Building Docker image locally..."
151+ @docker build -t apprun:local -f docker/Dockerfile .
152+ @echo " ✅ Docker image built: apprun:local"
153+ @echo " "
154+ @docker images apprun:local
155+
156+ # Run integration tests with local build
157+ test-local : build-local
158+ @echo " 🧪 Running integration tests..."
159+ @docker compose -f docker-compose.local.yml up -d
160+ @echo " ⏳ Waiting for services to be ready..."
161+ @sleep 15
162+ @echo " 🔍 Checking health..."
163+ @docker exec apprun-app-local wget -q -O- http://localhost:8080/health || (echo " ❌ Health check failed" && docker compose -f docker-compose.local.yml down && exit 1)
164+ @echo " ✅ Integration tests passed!"
165+ @docker compose -f docker-compose.local.yml down
166+
167+ # Start production-like environment locally
168+ prod-up-local :
169+ @echo " 🚀 Starting production-like environment locally..."
170+ @docker compose -f docker-compose.local.yml up -d
171+ @echo " ✅ Local production environment started!"
172+ @echo " "
173+ @echo " 🔗 Access:"
174+ @echo " HTTP: http://localhost:8080"
175+ @echo " HTTPS: https://localhost:8443"
176+ @echo " "
177+ @echo " 📊 View logs:"
178+ @echo " docker compose -f docker-compose.local.yml logs -f"
179+
180+ # Stop local production environment
181+ prod-down-local :
182+ @echo " 🛑 Stopping local production environment..."
183+ @docker compose -f docker-compose.local.yml down
184+ @echo " ✅ Local production environment stopped"
185+
186+ # Clean all Docker resources
187+ clean-docker :
188+ @echo " 🧹 Cleaning Docker resources..."
189+ @docker compose -f docker-compose.dev.yml down -v
190+ @docker compose -f docker-compose.local.yml down -v
191+ @docker rmi apprun:local 2> /dev/null || true
192+ @echo " ✅ Docker resources cleaned"
0 commit comments