This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Commit 2a4ddf3
committed
77c3fa3 docs: [#14] add comprehensive integration testing guide execution instructions (Jose Celano)
613b5df docs: [#14] add application storage cleanup step to integration testing guide (Jose Celano)
cc87760 fix: nginx template variable escaping and add documentation (Jose Celano)
f09efaf refactor: [#14] move configuration files to infrastructure layer (Jose Celano)
a8b11c5 refactor: move nginx.conf to infrastructure templates and improve configuration management (Jose Celano)
10592d0 feat: [#14] Complete integration test refactoring and verification (Jose Celano)
a0456e8 refactor: [#14] align integration tests with 12-factor configuration approach (Jose Celano)
00e13bf docs: update integration testing guide with comprehensive smoke tests and fixes (Jose Celano)
9bbd7bf docs: [#14] update integration testing guide with network architecture and proper testing procedures (Jose Celano)
458546a fix: [#14] resolve tracker database driver configuration issue (Jose Celano)
0c9d081 docs: [#integration-tests] add OpenTofu state refresh step to prevent IP detection issues (Jose Celano)
59bdd15 docs: improve integration testing guide with directory indicators and new config workflow (Jose Celano)
83d62f0 docs: add security documentation for plain text secrets (Jose Celano)
770fe25 fix: correct environment variable names and database config (Jose Celano)
2d19b12 refactor: simplify environment variables to secrets-only approach (Jose Celano)
6b46ddd fix: [#14] resolve yamllint validation warnings in config scripts (Jose Celano)
94d278b feat: [#14] implement Phase 1 of 12-Factor App refactor - configuration management (Jose Celano)
Pull request description:
## Phase 1: Configuration Management System
This PR implements the first phase of the 12-Factor App refactoring for the Torrust Tracker Demo, focusing on configuration management and environment-based deployment.
### 🎯 **Objectives Completed**
- ✅ **Environment-based configuration** using `.env` files and templates
- ✅ **Configuration templates** with `envsubst` for dynamic generation
- ✅ **Automated configuration scripts** with validation and colored output
- ✅ **Docker Compose integration** with generated environment files
- ✅ **Makefile automation** for configuration and deployment workflows
- ✅ **MySQL database migration** from SQLite for production readiness
### 🏗️ **Architecture Changes**
#### Configuration Structure
```
infrastructure/config/
├── environments/
│ ├── local.env # Local development configuration
│ └── production.env # Production deployment configuration
└── templates/
├── tracker.toml.tpl # Torrust Tracker configuration template
├── prometheus.yml.tpl # Prometheus monitoring template
└── docker-compose.env.tpl # Docker Compose environment template
```
#### New Automation Scripts
- **`configure-env.sh`** - Processes templates and generates configuration files
- **`validate-config.sh`** - Validates generated configurations for syntax and completeness
#### Enhanced Makefile Targets
- `configure-local` / `configure-production` - Generate environment-specific configs
- `validate-config` / `validate-config-production` - Validate configurations
- `deploy-local` / `deploy-production` - Full deployment workflows
### 🔧 **Key Features**
#### 1. **Template-Based Configuration**
All configuration files are now generated from templates using environment variables:
- No more hardcoded values in configuration files
- Environment-specific settings (logging levels, database URLs, etc.)
- Secrets management through environment variables
#### 2. **Environment Separation**
- **Local**: Debug logging, direct access, SQLite/MySQL support
- **Production**: Info logging, reverse proxy mode, MySQL database, SSL ready
#### 3. **Validation & Quality Assurance**
- TOML and YAML syntax validation
- Environment-specific configuration checks
- Template variable substitution verification
- Linting integration with project standards
#### 4. **Docker Compose Integration**
- Generated `.env` files for Docker Compose
- Consistent variable naming across all services
- Environment-specific service configurations
### 🚀 **Usage**
#### Quick Start - Local Development
```bash
make configure-local # Generate local configurations
make validate-config # Validate configurations
make deploy-local # Deploy with local settings
```
#### Production Deployment
```bash
# Set required secrets as environment variables
export TORRUST_PROD_DATABASE_URL="mysql://user:pass@host:3306/db"
export TORRUST_PROD_API_TOKEN="your-api-token"
# ... other production secrets
make configure-production # Generate production configurations
make validate-config-production # Validate configurations
make deploy-production # Deploy to production
```
### 🛡️ **Security Improvements**
- **No hardcoded secrets** - All sensitive values use environment variables
- **Environment isolation** - Clear separation between local and production configs
- **Validation safeguards** - Prevent deployment with misconfigured settings
### 📋 **Breaking Changes**
- Configuration files are now generated and should not be edited directly
- `.env` files must be generated using the new scripts
- Database configuration now defaults to MySQL for both environments
### 🧪 **Testing**
All changes have been validated with:
- ✅ **Linting** - yamllint, shellcheck, markdownlint
- ✅ **Configuration validation** - Both local and production environments
- ✅ **Template processing** - All templates generate correctly
- ✅ **Docker Compose integration** - Services start with generated configs
### 📚 **Documentation**
Updated documentation includes:
- Phase 1 implementation guide with detailed migration steps
- Configuration management workflow documentation
- Makefile target reference and usage examples
### 🔄 **Next Steps (Future PRs)**
- **Phase 2**: Infrastructure as Code enhancements
- **Phase 3**: Service isolation and containerization improvements
- **Phase 4**: Monitoring and observability integrations
---
**Ready for Review**: This PR represents a complete Phase 1 implementation of the 12-Factor App methodology. All existing functionality is preserved while adding robust configuration management capabilities.
ACKs for top commit:
josecelano:
ACK 77c3fa3
Tree-SHA512: 359047b1b8d34aa9586e26011c6ab33fd9d28a5a3f931ff9eef3d1d67c7ee2680f8feaf9231ea761a6d33987f0e6695fd3611130144ae5cf7b4a2618bbf5104d
File tree
24 files changed
+2684
-289
lines changed- .github/prompts
- application
- docs
- adr
- guides
- refactoring
- infrastructure
- config
- environments
- templates
- docs/refactoring/twelve-factor-refactor
- scripts
- tests
24 files changed
+2684
-289
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
193 | 209 | | |
194 | 210 | | |
195 | 211 | | |
| |||
342 | 358 | | |
343 | 359 | | |
344 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | | - | |
5 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
6 | 16 | | |
7 | 17 | | |
| 18 | + | |
| 19 | + | |
8 | 20 | | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
12 | 24 | | |
13 | 25 | | |
| 26 | + | |
14 | 27 | | |
15 | | - | |
16 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
17 | 36 | | |
18 | 37 | | |
| 38 | + | |
| 39 | + | |
19 | 40 | | |
20 | 41 | | |
21 | 42 | | |
| |||
33 | 54 | | |
34 | 55 | | |
35 | 56 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
39 | 67 | | |
40 | 68 | | |
| 69 | + | |
| 70 | + | |
41 | 71 | | |
42 | 72 | | |
43 | 73 | | |
44 | 74 | | |
| 75 | + | |
45 | 76 | | |
46 | | - | |
47 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
48 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments