Skip to content

Commit 18a219c

Browse files
committed
feat: add design document for tracker version coupling
1 parent 11ebafc commit 18a219c

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Design Prop
2+
3+
## 1. Overview
4+
5+
This document proposes a design to decouple the Torrust Tracker Demo installer from specific
6+
tracker versions. The current implementation has an implicit dependency on a single tracker
7+
version, which limits flexibility and makes upgrades difficult. This proposal introduces a
8+
version management system that allows users to specify the desired tracker version for
9+
deployment.
10+
11+
## 2. Problem Statement
12+
13+
The current deployment process is tightly coupled to a specific version of the Torrust
14+
Tracker. This coupling manifests in two key areas:
15+
16+
1. **Docker Image**: The `docker-compose.yaml` file references a hardcoded Docker
17+
image tag, which corresponds to a specific tracker release.
18+
2. **Configuration Templates**: The configuration templates (e.g.,
19+
`tracker.toml.tpl`) are designed for a specific tracker version and may not
20+
be compatible with other releases.
21+
22+
This tight coupling makes it difficult to:
23+
24+
- Deploy older or newer versions of the tracker.
25+
- Test different tracker releases in a consistent manner.
26+
- Manage configuration changes between tracker versions.
27+
28+
## 3. Proposed Solution
29+
30+
We will implement a version management system that allows users to define the desired
31+
tracker version in their deployment configuration. This system will consist of the
32+
following components:
33+
34+
### 3.1. User-Defined Tracker Version
35+
36+
The user will specify the tracker version in the environment configuration file
37+
(e.g., `development-libvirt.env`). A new variable, `TRACKER_VERSION`, will be
38+
introduced for this purpose.
39+
40+
**Example Configuration (`development-libvirt.env`):**
41+
42+
```env
43+
# ... other configuration ...
44+
45+
# -- Tracker Version Configuration --
46+
# Specifies the version of the Torrust Tracker to deploy.
47+
# Can be a specific version (e.g., "v2.0.0") or "latest".
48+
TRACKER_VERSION=v2.0.0
49+
```
50+
51+
### 3.2. Version-Specific Docker Images
52+
53+
The `docker-compose.yaml` file will be updated to use the `TRACKER_VERSION` variable to
54+
dynamically select the appropriate Docker image.
55+
56+
**Example `compose.yaml`:**
57+
58+
```yaml
59+
services:
60+
tracker:
61+
image: ghcr.io/torrust/torrust-tracker:${TRACKER_VERSION:-latest}
62+
# ... other service configuration ...
63+
```
64+
65+
This change allows the deployment to pull the correct Docker image based on the user's
66+
configuration. The `:-latest` default ensures backward compatibility and provides a
67+
sensible default if the variable is not set.
68+
69+
### 3.3. Versioned Configuration Templates
70+
71+
To manage configuration differences between tracker releases, we will introduce a
72+
versioned directory structure for configuration templates.
73+
74+
**Proposed Directory Structure:**
75+
76+
```text
77+
application/
78+
└── config/
79+
└── templates/
80+
└── tracker/
81+
├── v2.0.0/
82+
│ └── tracker.toml.tpl
83+
├── v2.1.0/
84+
│ └── tracker.toml.tpl
85+
└── latest/
86+
└── tracker.toml.tpl
87+
```
88+
89+
The deployment script (`configure-app.sh`) will be updated to select the appropriate
90+
template directory based on the `TRACKER_VERSION` variable.
91+
92+
**Deployment Logic (`configure-app.sh`):**
93+
94+
```bash
95+
# ... other script logic ...
96+
97+
# Determine the template directory based on the tracker version
98+
if [ -d "application/config/templates/tracker/${TRACKER_VERSION}" ]; then
99+
TEMPLATE_DIR="application/config/templates/tracker/${TRACKER_VERSION}"
100+
else
101+
# Fallback to the 'latest' templates if the specific version is not found
102+
TEMPLATE_DIR="application/config/templates/tracker/latest"
103+
fi
104+
105+
# Process the tracker configuration template
106+
envsubst < "${TEMPLATE_DIR}/tracker.toml.tpl" > "path/to/generated/tracker.toml"
107+
108+
# ... other script logic ...
109+
```
110+
111+
This approach ensures that the generated configuration is always compatible with the
112+
deployed tracker version.
113+
114+
### 3.4. "Latest" Version Support
115+
116+
A special version, `latest`, will be supported to facilitate testing and development.
117+
When `TRACKER_VERSION` is set to `latest`:
118+
119+
- The deployment will use the `latest` tag for the Docker image, which typically
120+
corresponds to the tracker's development branch.
121+
- The configuration templates from the
122+
`application/config/templates/tracker/latest/` directory will be used.
123+
124+
This allows for continuous integration and testing against the most recent tracker
125+
updates without requiring a new release.
126+
127+
## 4. Implementation Plan
128+
129+
1. **Add `TRACKER_VERSION` to Environment Configuration**:
130+
131+
- Update all environment configuration files (`*.env`) to include the `TRACKER_VERSION` variable.
132+
- Set a sensible default (e.g., the current stable release).
133+
134+
2. **Update `docker-compose.yaml`**:
135+
136+
- Modify the `tracker` service to use the `TRACKER_VERSION` variable for the image tag.
137+
138+
3. **Create Versioned Template Directories**:
139+
140+
- Reorganize the tracker configuration templates into the versioned directory
141+
structure described above.
142+
- Ensure that templates for all supported tracker versions are available.
143+
144+
4. **Update Deployment Scripts**:
145+
- Modify `configure-app.sh` to select the correct template directory based on `TRACKER_VERSION`.
146+
- Add logic to fall back to the `latest` directory if a specific version is not found.
147+
148+
## 5. Benefits
149+
150+
- **Flexibility**: Users can deploy any supported version of the Torrust Tracker.
151+
- **Maintainability**: Configuration changes between tracker versions are managed
152+
in a structured and predictable way.
153+
- **Testability**: The "latest" version support allows for continuous testing
154+
against the tracker's development branch.
155+
- **Clarity**: The deployment configuration explicitly defines the tracker version,
156+
making the deployment process more transparent.

0 commit comments

Comments
 (0)