Skip to content

Commit 621382c

Browse files
committed
docs: organize migration plan in new plans section
- Create docs/plans/ directory for ongoing strategic plans - Move migration plan to docs/plans/hetzner-migration-plan.md - Add plans documentation guidelines in docs/plans/README.md - Update docs/README.md to include plans section - Remove timeline estimates from migration plan for flexibility - Establish documentation structure for future strategic initiatives
1 parent e4076d1 commit 621382c

File tree

4 files changed

+332
-0
lines changed

4 files changed

+332
-0
lines changed

docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ This directory currently contains cross-cutting documentation:
1919
- [ADR-001: Makefile Location](adr/001-makefile-location.md) - Decision to keep
2020
Makefile at repository root level
2121

22+
### 📅 [`plans/`](plans/) (Ongoing Plans and Roadmaps)
23+
24+
**Current Plans:**
25+
26+
- [Hetzner Migration Plan](plans/hetzner-migration-plan.md) - Comprehensive plan
27+
for migrating from Digital Ocean to Hetzner infrastructure
28+
2229
### Future Categories
2330

2431
The following directories can be created as needed:
@@ -53,6 +60,7 @@ When adding new documentation:
5360
2. **Use this directory for cross-cutting concerns only**
5461

5562
- Architecture decisions affecting multiple layers
63+
- Ongoing plans and roadmaps spanning multiple phases
5664
- Research spanning infrastructure and application
5765
- Theoretical concepts and protocols
5866
- Performance analysis of the complete system
@@ -70,6 +78,7 @@ When adding new documentation:
7078
## Documentation Guidelines
7179

7280
- **Cross-cutting vs Specific**: Keep layer-specific docs in their respective directories
81+
- **Plans**: Should document strategic initiatives, migration plans, and multi-phase projects
7382
- **Research**: Should document findings, methodology, and conclusions
7483
- **ADRs**: Should follow standard ADR template format and affect multiple layers
7584
- **Theory**: Should explain concepts clearly with examples when possible

docs/plans/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Plans and Roadmaps
2+
3+
This directory contains ongoing strategic plans, migration roadmaps, and multi-phase
4+
project documentation that spans across infrastructure and application concerns.
5+
6+
## Current Plans
7+
8+
### [Hetzner Migration Plan](hetzner-migration-plan.md)
9+
10+
Comprehensive migration plan for moving the Torrust Tracker demo from Digital Ocean
11+
to Hetzner infrastructure. This plan includes:
12+
13+
- Database migration from SQLite to MySQL
14+
- 12-Factor App refactoring
15+
- Complete deployment automation
16+
- Hetzner Cloud provider implementation
17+
- Testing and validation procedures
18+
- Go-live strategy
19+
20+
**Status**: Planning phase
21+
**Timeline**: 8-12 weeks estimated
22+
**Scope**: Full infrastructure migration with modernization
23+
24+
## Plan Documentation Guidelines
25+
26+
When creating new plans:
27+
28+
1. **Use descriptive filenames** that clearly indicate the plan scope
29+
2. **Include timeline estimates** with realistic expectations
30+
3. **Break down into phases** for complex multi-step plans
31+
4. **Define clear deliverables** for each phase
32+
5. **Include validation criteria** to measure success
33+
6. **Document rollback strategies** for critical changes
34+
7. **Cross-reference** related documentation and issues
35+
36+
## Plan Status
37+
38+
Plans should include a status indicator:
39+
40+
- **Planning**: Initial planning and research phase
41+
- **In Progress**: Active implementation underway
42+
- **Testing**: Implementation complete, testing in progress
43+
- **Completed**: Plan successfully implemented
44+
- **On Hold**: Temporarily paused
45+
- **Cancelled**: Plan discontinued
46+
47+
## Plan Structure
48+
49+
Recommended structure for plan documents:
50+
51+
```markdown
52+
# Plan Title
53+
54+
## Overview
55+
56+
Brief description and objectives
57+
58+
## Key Decisions
59+
60+
Major strategic decisions and rationale
61+
62+
## Phases
63+
64+
Detailed breakdown of implementation phases
65+
66+
## Timeline
67+
68+
Realistic estimates with dependencies
69+
70+
## Success Criteria
71+
72+
Clear metrics for measuring completion
73+
74+
## Risk Mitigation
75+
76+
Rollback plans and risk management
77+
```
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# Torrust Tracker Demo Migration Plan - Digital Ocean to Hetzner
2+
3+
## Overview
4+
5+
This plan outlines the migration of the Torrust Tracker demo from Digital Ocean to Hetzner
6+
infrastructure. The migration prioritizes **ease of updates** over performance by maintaining
7+
Docker-based deployments, and follows a **complete local development and testing** approach
8+
before deploying to production.
9+
10+
## Key Decisions
11+
12+
- **Docker-first approach**: Continue using Docker for the tracker to simplify updates
13+
(just pull new images)
14+
- **Complete local testing**: Finish all development and testing locally before creating
15+
any Hetzner VMs
16+
- **MySQL by default**: Replace SQLite with MySQL for better production characteristics
17+
- **12-Factor App compliance**: Refactor the entire repository to follow modern deployment
18+
practices
19+
20+
## Migration Phases
21+
22+
### Phase 1: Database Migration to MySQL
23+
24+
**Objective**: Replace SQLite with MySQL as the default database
25+
26+
#### Tasks
27+
28+
- [ ] Add MySQL service to `docker-compose.yaml`
29+
- [ ] Update tracker configuration (`tracker.toml`) to use MySQL connection
30+
- [ ] Create MySQL initialization scripts/schema
31+
- [ ] Update environment variable templates (`.env.production`)
32+
- [ ] Update documentation for MySQL setup
33+
34+
#### Validation
35+
36+
- [ ] Deploy locally using `make apply`
37+
- [ ] Verify MySQL service starts successfully
38+
- [ ] Make test announce request
39+
- [ ] Confirm download counter increases in MySQL `torrents` table
40+
- [ ] Test tracker restart with persistent MySQL data
41+
42+
**Deliverable**: Working local deployment with MySQL backend
43+
44+
---
45+
46+
### Phase 2: 12-Factor App Refactoring
47+
48+
**Objective**: Refactor repository to follow [12-Factor App methodology](https://12factor.net/)
49+
50+
**Reference**: See detailed plan in `infrastructure/docs/refactoring/twelve-factor-refactor/`
51+
52+
#### Key Changes
53+
54+
- [ ] **Configuration via environment**: Move all config to environment variables
55+
- [ ] **Dependency isolation**: Explicit dependency declaration in Docker
56+
- [ ] **Stateless processes**: Ensure tracker processes are stateless
57+
- [ ] **Port binding**: Clean service port configuration
58+
- [ ] **Logs as streams**: Structured logging to stdout/stderr
59+
- [ ] **Environment parity**: Dev/staging/prod environment consistency
60+
61+
#### Tasks
62+
63+
- [ ] Implement configuration refactoring (see phase-1-implementation.md)
64+
- [ ] Update Docker configurations
65+
- [ ] Refactor environment variable management
66+
- [ ] Update deployment scripts
67+
- [ ] Update documentation
68+
69+
**Deliverable**: 12-Factor compliant repository structure
70+
71+
---
72+
73+
### Phase 3: Complete Application Installation Automation
74+
75+
**Objective**: Fully automate tracker deployment including SSL certificates
76+
77+
#### Current State
78+
79+
- ✅ VM provisioning via cloud-init
80+
- ✅ Basic app setup (copy files, `.env` config, `docker compose up`)
81+
- ❌ SSL certificate generation
82+
- ❌ Crontab setup for renewals
83+
- ❌ Production hardening steps
84+
85+
#### Tasks
86+
87+
- [ ] Automate SSL certificate generation with Certbot
88+
- [ ] Set up automatic certificate renewal crontabs
89+
- [ ] Implement production hardening automation
90+
- [ ] Create comprehensive deployment validation script
91+
- [ ] Handle edge cases and error recovery
92+
93+
#### Implementation Notes
94+
95+
- Integrate with existing cloud-init setup
96+
- If Certbot automation requires manual interaction, document as the only manual step
97+
- Follow production setup guide: https://torrust.com/blog/deploying-torrust-to-production
98+
99+
**Deliverable**: One-command deployment to production-ready state
100+
101+
---
102+
103+
### Phase 4: Hetzner Infrastructure Implementation
104+
105+
**Objective**: Add Hetzner Cloud provider support and validate complete deployment
106+
107+
#### Tasks
108+
109+
- [ ] Research and add Hetzner Cloud OpenTofu provider
110+
- [ ] Create Hetzner-specific Terraform configurations
111+
- [ ] Implement Hetzner cloud-init adaptations
112+
- [ ] Test complete deployment pipeline on Hetzner
113+
- [ ] Configure provider-level firewall (optional, complementing VM firewall)
114+
- [ ] Validate tracker accessibility via IP (HTTP)
115+
116+
#### Provider Firewall Consideration
117+
118+
- VM firewall via cloud-init: ✅ Required
119+
- Provider firewall: 🤔 Optional additional security layer
120+
121+
#### Validation
122+
123+
- [ ] Deploy test VM on Hetzner
124+
- [ ] Verify all services start correctly
125+
- [ ] Test tracker functionality (announce, scrape)
126+
- [ ] Confirm firewall rules work correctly
127+
- [ ] Performance and connectivity testing
128+
129+
**Deliverable**: Working Hetzner deployment with IP access
130+
131+
---
132+
133+
### Phase 5: Database Migration (Optional)
134+
135+
**Objective**: Migrate existing tracker data from Digital Ocean SQLite to Hetzner MySQL
136+
137+
#### Tasks
138+
139+
- [ ] Export existing SQLite data from Digital Ocean instance
140+
- [ ] Create data transformation scripts (SQLite → MySQL)
141+
- [ ] Import data to new MySQL instance
142+
- [ ] Validate data integrity and completeness
143+
- [ ] Test tracker with migrated data
144+
145+
**Note**: This step is optional and can be skipped for a fresh start
146+
147+
---
148+
149+
### Phase 6: Testing and Validation
150+
151+
**Objective**: Comprehensive testing of the new Hetzner deployment
152+
153+
#### Testing Areas
154+
155+
- [ ] **Functional Testing**: All tracker endpoints work correctly
156+
- [ ] **Performance Testing**: Announce/scrape response times
157+
- [ ] **Integration Testing**: Index ↔ Tracker communication
158+
- [ ] **Monitoring**: Grafana dashboards show correct metrics
159+
- [ ] **SSL Testing**: HTTPS certificate generation and renewal
160+
- [ ] **Backup Testing**: Database backup and restore procedures
161+
162+
#### Test Scenarios
163+
164+
- [ ] Fresh torrent announce and scrape
165+
- [ ] High-load announce testing
166+
- [ ] Tracker restart with data persistence
167+
- [ ] Certificate renewal simulation
168+
- [ ] Firewall rule validation
169+
170+
**Deliverable**: Fully validated production deployment
171+
172+
---
173+
174+
### Phase 7: Go Live
175+
176+
**Objective**: Switch production traffic to Hetzner infrastructure
177+
178+
#### Pre-Go-Live
179+
180+
- [ ] Consider static IP allocation on Hetzner
181+
- [ ] Prepare DNS change procedures
182+
- [ ] Document rollback plan
183+
184+
#### Go-Live Steps
185+
186+
- [ ] Update DNS records to point to new Hetzner IP
187+
- [ ] Update Digital Ocean index configuration:
188+
- Change tracker resolution from Docker service name to public domain
189+
- Index will access tracker via public API instead of internal Docker network
190+
- [ ] Monitor traffic and error rates
191+
- [ ] Validate end-to-end functionality
192+
193+
#### Post-Go-Live
194+
195+
- [ ] Monitor system stability for 24-48 hours
196+
- [ ] Verify certificate auto-renewal works
197+
- [ ] Confirm backup procedures
198+
- [ ] Update documentation with new procedures
199+
200+
**Deliverable**: Production traffic on Hetzner infrastructure
201+
202+
---
203+
204+
## Future Considerations
205+
206+
### Dynamic Configuration (Future Work)
207+
208+
Currently hardcoded in cloud-init:
209+
210+
- Number of tracker instances (e.g., 2 UDP trackers on ports 6868, 6969)
211+
- Firewall port configurations
212+
- Service scaling parameters
213+
214+
**Future Enhancement**: Inject dynamic configuration via template variables
215+
216+
### Repository Template Usage
217+
218+
This repository serves as a template for users deploying their own trackers. Current
219+
hardcoded configurations can be manually adapted, but future work could make this more
220+
dynamic.
221+
222+
## Risk Mitigation
223+
224+
### Rollback Plan
225+
226+
- Keep Digital Ocean instance running until Hetzner deployment is fully validated
227+
- Maintain DNS rollback capability
228+
- Document emergency procedures
229+
230+
### Testing Strategy
231+
232+
- All changes tested locally before Hetzner deployment
233+
- Staged rollout with validation at each phase
234+
- Comprehensive testing before DNS switch
235+
236+
## Success Criteria
237+
238+
- [ ] Tracker accessible via HTTPS on Hetzner
239+
- [ ] MySQL database working with persistent data
240+
- [ ] Grafana monitoring functional
241+
- [ ] SSL certificates auto-renewing
242+
- [ ] Index successfully communicating with tracker
243+
- [ ] Performance equivalent to or better than Digital Ocean
244+
- [ ] 12-Factor App compliance achieved
245+
- [ ] One-command deployment working

project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ commoninit
1010
conntrack
1111
containerd
1212
CPUS
13+
crontabs
1314
dialout
1415
direnv
1516
dmacvicar

0 commit comments

Comments
 (0)