@@ -20,8 +20,9 @@ This project implements a **four-step deployment workflow** aligned with twelve-
20
20
21
21
Create environment-specific configuration from templates:
22
22
23
- - ** Local Development** : ` infrastructure/config/environments/local.env.tpl ` → ` local.env `
24
- - ** Production** : ` infrastructure/config/environments/production.env.tpl ` → ` production.env `
23
+ - ** Development Environment** : ` development-libvirt.env ` (default) or custom name like ` my-dev.env `
24
+ - ** End-to-end Testing** : ` e2e-libvirt.env ` (default) or custom name like ` ci-test.env `
25
+ - ** Production Environment** : ` production-hetzner.env ` (default) or custom name like ` prod.env `
25
26
26
27
The environment file contains ** all deployment configuration** , including:
27
28
@@ -66,8 +67,37 @@ Verify deployment health and functionality:
66
67
- ** OpenTofu** (or Terraform) installed
67
68
- ** Git** for repository access
68
69
- ** SSH client** for server access
70
+ - ** SSH key pair** for VM access (see SSH Key Configuration below)
69
71
- ** Domain name** (required for HTTPS certificates in production)
70
72
73
+ #### SSH Key Configuration
74
+
75
+ The deployment system requires an SSH public key for secure VM access. The system
76
+ automatically detects SSH keys from these locations (in order):
77
+
78
+ 1 . ` ~/.ssh/torrust_rsa.pub ` (recommended - dedicated key for Torrust deployments)
79
+ 2 . ` ~/.ssh/id_rsa.pub ` (common default SSH key)
80
+ 3 . ` ~/.ssh/id_ed25519.pub ` (Ed25519 SSH key)
81
+ 4 . ` ~/.ssh/id_ecdsa.pub ` (ECDSA SSH key)
82
+
83
+ ** Recommended Setup** :
84
+
85
+ ``` bash
86
+ # Generate dedicated SSH key for Torrust deployments
87
+ ssh-keygen -t rsa -b 4096 -f
~ /.ssh/torrust_rsa -C
" [email protected] "
88
+
89
+ # The public key (~/.ssh/torrust_rsa.pub) will be auto-detected
90
+ # The private key (~/.ssh/torrust_rsa) will be used for SSH connections
91
+ ```
92
+
93
+ ** Alternative Options** :
94
+
95
+ - ** Use existing key** : Copy your existing public key to ` ~/.ssh/torrust_rsa.pub `
96
+ - ** Manual configuration** : Set ` SSH_PUBLIC_KEY ` in your environment file
97
+ - ** Environment variable** : Export the key content as an environment variable
98
+
99
+ If no SSH key is found, the deployment will provide detailed error messages with setup instructions.
100
+
71
101
### Cloud Provider Requirements (For Future Implementation)
72
102
73
103
When cloud providers are implemented, they will need:
@@ -90,10 +120,18 @@ cloud-agnostic to facilitate adding cloud providers that support cloud-init in t
90
120
91
121
## Quick Start
92
122
93
- ### Current Implementation: Local Development
123
+ ### Current Implementation: Development Environment (KVM/libvirt)
94
124
95
- The current implementation supports local KVM/libvirt deployment, which is perfect
96
- for development, testing, and understanding the system before cloud deployment.
125
+ The current implementation supports local KVM/libvirt deployment using the ** development**
126
+ environment type, which is perfect for development, testing, and understanding the system
127
+ before cloud deployment.
128
+
129
+ ** Environment Types vs Environment Files** :
130
+
131
+ - ** Environment Types** : ` development ` , ` testing ` , ` e2e ` , ` staging ` , ` production `
132
+ - ** Environment Files** : Any name you choose (e.g., ` my-dev.env ` , ` local-test.env ` )
133
+ - ** Default Format** : ` {environment-type}-{provider}.env ` (when using generation scripts)
134
+ - ** Examples** : ` development-libvirt.env ` , ` production-hetzner.env ` , ` my-custom-setup.env `
97
135
98
136
### 1. Clone and Setup
99
137
@@ -105,22 +143,29 @@ cd torrust-tracker-demo
105
143
# Install dependencies (Ubuntu/Debian)
106
144
make install-deps
107
145
108
- # Configure SSH access for VMs
109
- make infra-config-local
146
+ # Setup SSH key for VM access (if you don't have ~/.ssh/torrust_rsa.pub)
147
+ ssh-keygen -t rsa -b 4096 -f
~ /.ssh/torrust_rsa -C
" [email protected] "
148
+
149
+ # The system will auto-detect ~/.ssh/torrust_rsa.pub during deployment
110
150
```
111
151
112
152
### 2. Local Testing with KVM/libvirt
113
153
114
154
``` bash
115
- # Test deployment locally with KVM
155
+ # Test deployment locally with KVM using development environment (default naming)
116
156
# Commands wait for full readiness by default
117
- make infra-apply ENVIRONMENT=local
118
- make app-deploy ENVIRONMENT=local
157
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
158
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
159
+ make app-health-check
160
+
161
+ # Alternative: Use custom file names
162
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=my-custom-dev
163
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=my-custom-dev
119
164
make app-health-check
120
165
121
166
# Advanced users: Skip waiting for faster execution
122
- make infra-apply ENVIRONMENT=local SKIP_WAIT=true
123
- make app-deploy ENVIRONMENT=local SKIP_WAIT=true
167
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
168
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
124
169
make app-health-check
125
170
126
171
# Access the local instance via SSH
@@ -134,17 +179,20 @@ make vm-ssh
134
179
make infra-destroy
135
180
```
136
181
182
+ ** Note** : ` ENVIRONMENT_FILE ` can be any filename (without ` .env ` extension).
183
+ The system looks for the file in ` infrastructure/config/environments/{filename}.env ` .
184
+
137
185
### 3. Cloud Deployment (Planned - Hetzner)
138
186
139
187
** Note** : Cloud deployment is not yet implemented. The following commands show the
140
188
planned interface for future Hetzner Cloud deployment:
141
189
142
190
``` bash
143
- # Planned: Deploy infrastructure to Hetzner Cloud
144
- make infra-apply ENVIRONMENT =production PROVIDER= hetzner
191
+ # Planned: Deploy infrastructure to Hetzner Cloud using production environment
192
+ make infra-apply ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production- hetzner
145
193
146
194
# Planned: Deploy application services
147
- make app-deploy ENVIRONMENT =production
195
+ make app-deploy ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
148
196
149
197
# Validate deployment
150
198
make app-health-check
@@ -315,9 +363,14 @@ default, providing a much better user experience:
315
363
316
364
``` bash
317
365
# Each command waits for full readiness by default
318
- make infra-apply ENVIRONMENT=local # Waits for VM IP + cloud-init completion
319
- make app-deploy ENVIRONMENT=local # Waits for all services to be healthy
320
- make app-health-check # Validates everything is working
366
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
367
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
368
+ make app-health-check
369
+
370
+ # What each command does:
371
+ # infra-apply: Waits for VM IP + cloud-init completion
372
+ # app-deploy: Waits for all services to be healthy
373
+ # health-check: Validates everything is working
321
374
```
322
375
323
376
** Key improvements** :
@@ -331,17 +384,17 @@ make app-health-check # Validates everything is working
331
384
332
385
``` bash
333
386
# Skip waiting for faster execution (original behavior)
334
- make infra-apply ENVIRONMENT=local SKIP_WAIT=true
335
- make app-deploy ENVIRONMENT=local SKIP_WAIT=true
387
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
388
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt SKIP_WAIT=true
336
389
```
337
390
338
391
### Infrastructure Deployment
339
392
340
393
The infrastructure deployment creates and configures the VM:
341
394
342
395
``` bash
343
- # Deploy infrastructure
344
- make infra-apply ENVIRONMENT=production
396
+ # Deploy infrastructure using development environment
397
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
345
398
346
399
# What this does:
347
400
# 1. Creates VM with Ubuntu 24.04
@@ -359,8 +412,8 @@ make infra-apply ENVIRONMENT=production
359
412
The application deployment sets up all services:
360
413
361
414
``` bash
362
- # Deploy application
363
- make app-deploy ENVIRONMENT=production
415
+ # Deploy application using development environment
416
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
364
417
365
418
# What this does:
366
419
# 1. Clones torrust-tracker-demo repository
@@ -478,18 +531,18 @@ docker compose exec -T mysql mysql -u root -p torrust_tracker
478
531
479
532
## Environment Configuration
480
533
481
- ### Local Development
534
+ ### Development Environment ( Local Testing)
482
535
483
- For local testing and development:
536
+ For local testing and development using KVM/libvirt :
484
537
485
538
``` bash
486
- # Use local environment
487
- make infra-apply ENVIRONMENT=local
488
- make app-deploy ENVIRONMENT=local
539
+ # Use development environment type with libvirt provider
540
+ make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
541
+ make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt
489
542
490
543
# Features enabled:
491
544
# - HTTPS with self-signed certificates (automatic)
492
- # - Local domain names (tracker.test.local, grafana. test.local)
545
+ # - Local domain names (test.local)
493
546
# - Full monitoring with Grafana and Prometheus
494
547
# - MySQL database (same as production)
495
548
# - All production features except trusted SSL certificates
@@ -535,10 +588,10 @@ Generate the production configuration template:
535
588
536
589
``` bash
537
590
# Generate production configuration template with placeholders
538
- make infra-config-production
591
+ make infra-config-production PROVIDER=hetzner
539
592
```
540
593
541
- This will create ` infrastructure/config/environments/production.env ` with secure placeholder
594
+ This will create ` infrastructure/config/environments/production-hetzner .env ` with secure placeholder
542
595
values that need to be replaced with your actual configuration.
543
596
544
597
#### Step 3: Replace Placeholder Values
@@ -547,7 +600,7 @@ Edit the generated production environment file with your secure secrets and doma
547
600
548
601
``` bash
549
602
# Edit the production configuration
550
- vim infrastructure/config/environments/production.env
603
+ vim infrastructure/config/environments/production-hetzner .env
551
604
```
552
605
553
606
** Replace these placeholder values with your actual configuration** :
@@ -594,9 +647,9 @@ make infra-config-production
594
647
planned interface for future production deployments:
595
648
596
649
``` bash
597
- # Planned: Use production environment
598
- make infra-apply ENVIRONMENT =production DOMAIN=your-domain.com
599
- make app-deploy ENVIRONMENT =production
650
+ # Planned: Use production environment type with Hetzner provider
651
+ make infra-apply ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
652
+ make app-deploy ENVIRONMENT_TYPE =production ENVIRONMENT_FILE=production-hetzner
600
653
601
654
# Planned features:
602
655
# - HTTPS support (with automated certificate setup)
0 commit comments