Files
tfm_ainventory/.planning/phases/06-deployment-scale/CONTEXT.md
Daniel Bedeleanu 4ea9625928 docs(phase-6): revise context - single-instance deployment, Docker only, no scale testing
- Lock decision: Single-instance Docker deployment (not multi-site)
- Remove scale testing from Phase 6 scope (defer to v3)
- Simplify to 2 plans: Docker deployment + operational runbook
- Update success criteria to focus on reliability, not performance testing
2026-04-22 18:17:45 +03:00

176 lines
6.8 KiB
Markdown

# Phase 6: Docker Deployment — Context & Strategic Overview
**Phase Goal**: Production-ready single-instance Docker deployment with automated setup and operational runbooks.
**Duration**: 2-3 weeks (simplified scope)
**Target Version**: v2.0 stable
**CRITICAL DECISION**: Single-instance deployment (not multi-site). Docker containerization only. No scale testing.
---
## Phase Overview
Phase 6 delivers containerized deployment for v2.0. After Phase 5 delivers search, exports, and quick quantity adjustment, the system needs:
1. **Containerization** — Reliable Docker/Compose setup for reliable deployment
2. **Automation** — Single-command deployment (`./deploy.sh`)
3. **Operational readiness** — Health checks, monitoring, runbook documentation
4. **Documentation** — Clear deployment and troubleshooting guides for operators
**OUT OF SCOPE**: Scale testing, multi-site federation, performance optimization, multi-instance clustering
---
## Key Decisions Made During Planning
### 1. Docker Strategy (LOCKED)
- **Existing**: docker-compose.yml and Dockerfiles already in place (backend/, proxy/)
- **Gap**: Automated deployment scripts, environment templates, health checks
- **Focus**: Enhance existing Dockerfiles → production-grade, add health checks, optimize layers
- **Deployment Target**: Single-instance Docker Compose (local development + production)
### 2. Deployment Automation (LOCKED)
- **Target**: `./deploy.sh` (single entry point) — no manual steps
- **Scope**: Config validation, DB initialization, certificate generation, health checks
- **Fallback**: Documented manual steps for troubleshooting
- **Testing**: Pre-flight checks (port availability, storage, permissions)
### 3. Scale Testing (DEFERRED - NOT IN PHASE 6)
- **Decision**: Application is single-instance. Scale testing (10K items + 5 concurrent users) deferred to v3.
- **Rationale**: Phase 5 delivered core features. Phase 6 focuses on reliable deployment, not load testing.
- **Future**: If multi-instance or multi-site deployment needed later, add scale testing then.
### 4. Operational Readiness (LOCKED)
- **Health Checks**: Docker healthchecks on all services
- **Monitoring**: Prometheus-style metrics endpoint (optional, documented)
- **Logging**: Centralized logs via Docker (stdout/stderr)
- **Documentation**: Runbook for deployment, troubleshooting, health monitoring
### 5. Operational Documentation (LOCKED)
- **Audience**: Ops teams deploying single-instance setups; minimal Docker/Python knowledge required
- **Format**: Runbook style (step-by-step checklists)
- **Coverage**: Deployment, monitoring, troubleshooting, upgrade path
- **OUT OF SCOPE**: Multi-site federation, scaling across instances
---
## Upstream Dependencies
### Phase 5 Completion Required
- ✓ Quick Quantity Adjustment feature (UI + API)
- ✓ Search & Filtering feature (modal + backend)
- ✓ Export/Reports feature (CSV/Excel + admin UI)
- ✓ All tests passing (Vitest + Pytest)
- ✓ No critical bugs in dev branch
### Existing Infrastructure
- ✓ docker-compose.yml (3 services: backend, frontend, proxy)
- ✓ Backend Dockerfile (Python 3.12 + FastAPI)
- ✓ Frontend Dockerfile (Node.js + Next.js)
- ✓ Caddy proxy with HTTPS (self-signed certs)
- ✓ Environment file system (inventory.env)
---
## Technical Approach (SIMPLIFIED)
### Plan 1: Docker & Deployment Automation (Week 1)
- Refine Dockerfiles (health checks, logging, layer optimization)
- Create deployment automation script (`./deploy.sh`)
- Environment template with validation (single-instance config)
- Pre-flight checks + error handling
- Docker Compose enhancements (healthchecks, volumes, networking)
- Health check integration tests
### Plan 2: Operational Runbook & Documentation (Week 2-3)
- Deployment runbook (step-by-step, fresh VM scenario)
- Health monitoring checklist (startup, daily, weekly checks)
- Troubleshooting guide (common issues + solutions)
- Upgrade procedure documentation
- Emergency procedures (container restart, data recovery)
- Optional: Prometheus metrics endpoint documentation
**Scale Testing Moved to v3 Backlog** — Focus on single-instance reliability instead.
---
## Success Criteria (SIMPLIFIED FOR SINGLE-INSTANCE)
### Deployment Automation
- [ ] `./deploy.sh` deploys full stack in <5 minutes
- [ ] Automatic DB initialization on first run
- [ ] Health checks confirm all services running
- [ ] Env validation prevents misconfiguration
- [ ] Works on clean Ubuntu 22.04+ LTS system (local Docker)
### Operational Documentation
- [ ] Deployment runbook (step-by-step, fresh VM scenario)
- [ ] Health monitoring checklist (startup, daily, weekly)
- [ ] Troubleshooting guide (common issues + solutions)
- [ ] Upgrade procedure documented
- [ ] Emergency procedures clear (restart, recovery)
### Quality Gates
- [ ] All Docker builds succeed with no warnings
- [ ] Health checks pass on fresh deployment
- [ ] All services accessible after deployment
- [ ] Documentation is accurate and complete
---
## Testing Strategy
### Automated Testing
- Pre-deployment validation (docker build, env checks)
- Health check validation (all services respond)
- Scale testing suite (Locust + Playwright)
- Backup/restore automated tests
### Manual Testing
- First-time deployment on fresh VM
- Multi-site deployment (verify isolation)
- Failover testing (service restart, data integrity)
### Success Metrics
- All automated tests pass
- Manual deployment completes without human intervention
- Scale test shows <2s latency at 5 concurrent users
- Backup/restore cycle succeeds with zero data loss
---
## Blockers & Workarounds
### Known Constraints
1. **Certificate persistence** — Caddy certs need stable volume mount
- Workaround: Use persistent named volumes for `/data/caddy_*`
2. **Environment variability** — Different deployments may have different network configs
- Workaround: Pre-flight checks validate critical assumptions (ports, storage)
3. **Single-instance limitation** — Application designed for single-instance; no clustering
- Accepted constraint for v2 scope
### Potential Issues
- Docker daemon availability (some restricted environments)
- HTTPS certificate warnings on first-time access
- Network isolation (VPN/Tailscale may affect CORS detection)
---
## Execution Checklist (UPDATED FOR SINGLE-INSTANCE SCOPE)
- [x] Phase 5 complete + all tests passing
- [x] Create Phase 6 directory structure
- [ ] Update PLAN.md files to match simplified scope (Docker + runbook only)
- [ ] Execute Plan 1: Docker + deploy.sh automation
- [ ] Execute Plan 2: Operational runbook & documentation
- [ ] Integration testing (fresh deployment + health checks)
- [ ] Documentation review
- [ ] Commit all changes with `feat(6): phase 6 deployment automation (single-instance)`
- [ ] Tag v2.0-rc1 for release candidate validation
---
**Last Updated**: 2026-04-22 (Planning Phase)