feat(docker-watcher): phase 7 - deployer & health checker

Deploy orchestrator with full pipeline: pull → create container →
start → network → NPM proxy → health check. Rollback on failure,
multi-instance support, max_instances enforcement, webhook notifications.
Fix NPM auth in rollback and error logging in removeInstance.
This commit is contained in:
2026-03-27 22:02:09 +03:00
parent eef60a4302
commit bbcc4f55f0
7 changed files with 301 additions and 22 deletions
+12 -12
View File
@@ -1,6 +1,6 @@
# Phase 7: Deployer & Health Checker
**Status:** ⬜ Not Started
**Status:** ✅ Complete
**Parent plan:** [PLAN.md](./PLAN.md)
**Domain:** backend
@@ -9,17 +9,17 @@ Implement the core deployment orchestrator: pull → start container → configu
## Tasks
- [ ] Task 1: Define deployer service struct — depends on Docker client, NPM client, store, notifier
- [ ] Task 2: Implement deploy flow: pull image → create container → start → connect to network → configure proxy → health check
- [ ] Task 3: Implement subdomain generation per convention: `stage-{stage}-{project}` for default, `stage-{stage}-{project}-{tag}` for specific
- [ ] Task 4: Sanitize tags for DNS (dots → dashes, lowercase, truncate)
- [ ] Task 5: Implement health checker — HTTP GET to `http://container:{port}{healthcheck_path}` with retries and timeout
- [ ] Task 6: Implement rollback on health check failure — remove new container, delete NPM proxy host, update instance status
- [ ] Task 7: Implement multi-instance support — multiple tags of same project/stage can run simultaneously
- [ ] Task 8: Implement max_instances enforcement — remove oldest instance when limit reached
- [ ] Task 9: Implement notification webhook — POST to configured URL on deploy success/failure
- [ ] Task 10: Create deploy history records in store (status, timestamps, logs)
- [ ] Task 11: Implement deploy log streaming — append log entries during deploy for real-time visibility
- [x] Task 1: Define deployer service struct — depends on Docker client, NPM client, store, notifier
- [x] Task 2: Implement deploy flow: pull image → create container → start → connect to network → configure proxy → health check
- [x] Task 3: Implement subdomain generation per convention: `stage-{stage}-{project}` for default, `stage-{stage}-{project}-{tag}` for specific
- [x] Task 4: Sanitize tags for DNS (dots → dashes, lowercase, truncate)
- [x] Task 5: Implement health checker — HTTP GET to `http://container:{port}{healthcheck_path}` with retries and timeout
- [x] Task 6: Implement rollback on health check failure — remove new container, delete NPM proxy host, update instance status
- [x] Task 7: Implement multi-instance support — multiple tags of same project/stage can run simultaneously
- [x] Task 8: Implement max_instances enforcement — remove oldest instance when limit reached
- [x] Task 9: Implement notification webhook — POST to configured URL on deploy success/failure
- [x] Task 10: Create deploy history records in store (status, timestamps, logs)
- [x] Task 11: Implement deploy log streaming — append log entries during deploy for real-time visibility
## Files to Modify/Create
- `internal/deployer/deployer.go` — main deploy orchestrator