74 lines
2.1 KiB
Markdown
74 lines
2.1 KiB
Markdown
# Deployment Tools: Makefile + HWID Migration
|
|
|
|
## TODOs
|
|
|
|
- [ ] 1. Create Makefile with reset-db command
|
|
|
|
**What to do**:
|
|
- Create `D:\www-project\NexusGuard\Makefile` with this content:
|
|
```makefile
|
|
.PHONY: up down reset-db logs dev migrate
|
|
|
|
up:
|
|
docker compose up -d
|
|
|
|
down:
|
|
docker compose down
|
|
|
|
logs:
|
|
docker compose logs -f
|
|
|
|
reset-db:
|
|
docker compose down -v
|
|
docker compose up -d postgres redis
|
|
@echo "Waiting for postgres to be ready..."
|
|
@for i in $$(seq 1 30); do \
|
|
docker compose exec -T postgres pg_isready -U nexusguard >/dev/null 2>&1 && break; \
|
|
echo " waiting... $$i"; \
|
|
sleep 2; \
|
|
done
|
|
cd apps/server-core && go run -tags dev . -migrate-prod
|
|
@echo ""
|
|
@echo "Database reset complete. Run 'make up' to start all services."
|
|
|
|
dev:
|
|
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
|
|
|
|
migrate:
|
|
cd apps/server-core && go run -tags dev . -migrate-prod
|
|
```
|
|
|
|
- Then run `cd D:\www-project\NexusGuard && git add Makefile`
|
|
|
|
**Recommended Agent Profile**: `build` (file creation + git)
|
|
|
|
- [ ] 2. SSH: Migrate empty HWIDs to NULL + restart container
|
|
|
|
**What to do**:
|
|
- SSH into 172.20.8.191:
|
|
```bash
|
|
ssh root@172.20.8.191 "docker exec nexus-guard-suite-postgres-1 psql -U nexusguard -d nexusguard -c \"UPDATE devices SET hwid = NULL WHERE hwid = '';\""
|
|
```
|
|
- Then restart server-core:
|
|
```bash
|
|
ssh root@172.20.8.191 "docker restart nexus-guard-suite-server-core-1"
|
|
```
|
|
|
|
**QA Scenarios**:
|
|
```
|
|
Scenario: Verify no empty HWIDs remain
|
|
Tool: Bash
|
|
Steps:
|
|
1. ssh root@172.20.8.191 "docker exec nexus-guard-suite-postgres-1 psql -U nexusguard -d nexusguard -c \"SELECT count(*) FROM devices WHERE hwid = '';\""
|
|
Expected Result: count = 0
|
|
```
|
|
|
|
- [ ] 3. Commit and push all changes (server-core HWID fix, frontend delete button, Makefile)
|
|
|
|
- [ ] 4. Verify POST /api/v1/peers returns 201
|
|
|
|
```bash
|
|
ssh root@172.20.8.191 'curl -s -X POST http://localhost:3000/api/v1/auth/login -H "Content-Type: application/json" -d "{\"username\":\"admin\",\"password\":\"...\"}"'
|
|
# Then use token to create a peer
|
|
```
|