@fabioplunser/epd 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +925 -407
- package/docs/.vitepress/config.mts +49 -16
- package/docs/.vitepress/theme/DeployAnimation.vue +1259 -0
- package/docs/.vitepress/theme/index.ts +10 -0
- package/docs/.vitepress/theme/style.css +109 -0
- package/docs/ci-cd.md +8 -0
- package/docs/getting-started.md +244 -0
- package/docs/guide/accessories.md +103 -0
- package/docs/guide/architecture.md +94 -0
- package/docs/guide/blue-green.md +93 -0
- package/docs/guide/deployment-modes.md +135 -0
- package/docs/guide/getting-started.md +244 -0
- package/docs/guide/high-availability.md +89 -0
- package/docs/guide/installation.md +127 -0
- package/docs/guide/multi-site.md +101 -0
- package/docs/guide/routing.md +129 -0
- package/docs/guide/secrets.md +109 -0
- package/docs/guide/troubleshooting.md +109 -0
- package/docs/guide.md +172 -535
- package/docs/hetzner-dns.md +8 -0
- package/docs/index.md +20 -25
- package/docs/public/CNAME +1 -0
- package/docs/public/favicon.svg +52 -0
- package/docs/reference/cli.md +238 -0
- package/docs/reference/config.md +177 -0
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Advanced Routing & Traefik Features
|
|
2
|
+
|
|
3
|
+
Configure path-based routing, subdomain dispatch, HTTP redirects, basic authentication, sticky sessions, custom response headers, and wildcard SSL certificates.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The `routes:` Block
|
|
8
|
+
|
|
9
|
+
For simple applications, specifying `domains: [myapp.example.com]` is all you need. For fine-grained control, use the `routes:` block under any service in `epd.yml`:
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
servers:
|
|
13
|
+
web:
|
|
14
|
+
hosts: [203.0.113.10]
|
|
15
|
+
port: 3000
|
|
16
|
+
routes:
|
|
17
|
+
# 1. Standard Domain
|
|
18
|
+
- host: example.com
|
|
19
|
+
|
|
20
|
+
# 2. Subdomain Routed to a Different Container Port
|
|
21
|
+
- host: api.example.com
|
|
22
|
+
port: 8080
|
|
23
|
+
|
|
24
|
+
# 3. Path-Based Routing with Prefix Stripping
|
|
25
|
+
- host: example.com
|
|
26
|
+
path: /api/v1
|
|
27
|
+
port: 5000
|
|
28
|
+
strip_path: true
|
|
29
|
+
|
|
30
|
+
# 4. HTTP Basic Authentication Protection
|
|
31
|
+
- host: admin.example.com
|
|
32
|
+
basic_auth:
|
|
33
|
+
- "admin:$apr1$xyz$0123456789abcdefghijk."
|
|
34
|
+
|
|
35
|
+
# 5. Permanent Domain Redirect (HTTP 301)
|
|
36
|
+
- host: www.example.com
|
|
37
|
+
redirect: https://example.com
|
|
38
|
+
|
|
39
|
+
# 6. Temporary Redirect (HTTP 302)
|
|
40
|
+
- host: promo.example.com
|
|
41
|
+
redirect: https://example.com/summer-sale
|
|
42
|
+
permanent: false
|
|
43
|
+
|
|
44
|
+
# 7. Sticky Sessions for WebSockets
|
|
45
|
+
- host: chat.example.com
|
|
46
|
+
sticky: true
|
|
47
|
+
|
|
48
|
+
# 8. Security & Custom Headers
|
|
49
|
+
- host: secure.example.com
|
|
50
|
+
headers:
|
|
51
|
+
X-Frame-Options: "DENY"
|
|
52
|
+
X-Content-Type-Options: "nosniff"
|
|
53
|
+
Referrer-Policy: "strict-origin-when-cross-origin"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Route Features Breakdown
|
|
59
|
+
|
|
60
|
+
### Path Routing & Prefix Stripping
|
|
61
|
+
Direct requests matching `/docs` or `/api` to different container ports or backend microservices. Setting `strip_path: true` removes the prefix before the request reaches the container:
|
|
62
|
+
```yaml
|
|
63
|
+
- host: example.com
|
|
64
|
+
path: /blog
|
|
65
|
+
port: 8080
|
|
66
|
+
strip_path: true # Request for /blog/post-1 becomes /post-1 inside container
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Basic Authentication
|
|
70
|
+
Protect staging environments or internal admin panels with HTTP Basic Auth:
|
|
71
|
+
```yaml
|
|
72
|
+
- host: staging.example.com
|
|
73
|
+
basic_auth:
|
|
74
|
+
- "admin:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
::: tip Generating Basic Auth Hashes
|
|
78
|
+
Generate password hashes using Apache's `htpasswd`:
|
|
79
|
+
```bash
|
|
80
|
+
htpasswd -nb admin mypassword
|
|
81
|
+
```
|
|
82
|
+
:::
|
|
83
|
+
|
|
84
|
+
### Sticky Sessions (Cookie-Based Load Balancing)
|
|
85
|
+
When running multiple replicas, sticky sessions ensure an individual visitor remains connected to the same replica container (essential for in-memory socket state or stateful sessions):
|
|
86
|
+
```yaml
|
|
87
|
+
- host: socket.example.com
|
|
88
|
+
sticky: true
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Wildcard Certificates & DNS Challenges
|
|
94
|
+
|
|
95
|
+
Standard Let's Encrypt certificates use the `http` challenge on port 80. For wildcard domains (`*.example.com`), configure the DNS-01 challenge:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
proxy:
|
|
99
|
+
challenge: dns
|
|
100
|
+
dns_provider: cloudflare # or hetzner
|
|
101
|
+
dns_env:
|
|
102
|
+
- CF_DNS_API_TOKEN
|
|
103
|
+
|
|
104
|
+
servers:
|
|
105
|
+
web:
|
|
106
|
+
hosts: [203.0.113.10]
|
|
107
|
+
port: 3000
|
|
108
|
+
routes:
|
|
109
|
+
- host: "*.example.com"
|
|
110
|
+
priority: 1
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Inspecting Live Routes
|
|
116
|
+
|
|
117
|
+
To view the exact Traefik dynamic routing YAML generated on the server:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
epd proxy routes
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Next Steps
|
|
126
|
+
|
|
127
|
+
- Manage **[Secrets & Environment Variables](/guide/secrets)**
|
|
128
|
+
- Set up **[Persistent Accessories & Databases](/guide/accessories)**
|
|
129
|
+
- Learn about **[Multi-Provider DNS Automation](/hetzner-dns)**
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Secrets & Environment Management
|
|
2
|
+
|
|
3
|
+
Learn how `epd` securely manages environment variables, protects production secrets from git, and supports multi-environment staging overlays.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Core Principle
|
|
8
|
+
|
|
9
|
+
`epd` ensures secrets are:
|
|
10
|
+
- **Never committed to git.**
|
|
11
|
+
- **Never baked into Docker image layers.**
|
|
12
|
+
- **Never printed in shell histories or CI logs.**
|
|
13
|
+
- **Saved as restricted root-owned `0600` files on the host server.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. Declaring Variables in `epd.yml`
|
|
18
|
+
|
|
19
|
+
Separate non-sensitive public configuration from private credentials:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
env:
|
|
23
|
+
# Public, non-sensitive variables (safe to commit to git)
|
|
24
|
+
clear:
|
|
25
|
+
NODE_ENV: production
|
|
26
|
+
PORT: "3000"
|
|
27
|
+
LOG_LEVEL: info
|
|
28
|
+
|
|
29
|
+
# Sensitive secrets (read from your local environment or .env at deploy time)
|
|
30
|
+
secret:
|
|
31
|
+
- DATABASE_URL
|
|
32
|
+
- STRIPE_SECRET_KEY
|
|
33
|
+
- JWT_SECRET
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. How Secret Resolution Works
|
|
39
|
+
|
|
40
|
+
When you run `epd deploy`:
|
|
41
|
+
1. `epd` reads each secret named in `env.secret` from:
|
|
42
|
+
- Your local shell environment (`export DATABASE_URL=...`)
|
|
43
|
+
- `.env` or `.env.local` in your project root
|
|
44
|
+
- Destination-specific files like `.env.staging` (when using `-d staging`)
|
|
45
|
+
2. `epd` securely uploads these key-value pairs to `/var/lib/epd/apps/<app>/env` on the remote server with `chmod 0600`.
|
|
46
|
+
3. During startup:
|
|
47
|
+
- **Docker Mode**: Mounted securely into containers via `--env-file`.
|
|
48
|
+
- **Process Mode**: Loaded into PM2 process environments.
|
|
49
|
+
|
|
50
|
+
::: warning Missing Secrets
|
|
51
|
+
If a variable listed in `env.secret` is not found in your environment or `.env` file, `epd` halts deployment with a helpful error before modifying any remote state.
|
|
52
|
+
:::
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 3. Service-Specific Environments
|
|
57
|
+
|
|
58
|
+
You can also override environment variables for a specific server service:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
servers:
|
|
62
|
+
web:
|
|
63
|
+
hosts: [203.0.113.10]
|
|
64
|
+
port: 3000
|
|
65
|
+
env:
|
|
66
|
+
clear:
|
|
67
|
+
SERVICE_NAME: web-frontend
|
|
68
|
+
|
|
69
|
+
worker:
|
|
70
|
+
hosts: [203.0.113.10]
|
|
71
|
+
command: bun run worker.ts
|
|
72
|
+
env:
|
|
73
|
+
clear:
|
|
74
|
+
CONCURRENCY: "10"
|
|
75
|
+
secret:
|
|
76
|
+
- REDIS_PASSWORD
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 4. Multi-Environment Overlays (Staging vs. Production)
|
|
82
|
+
|
|
83
|
+
Manage multiple environments without duplicating configuration files:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Deploys using epd.yml + merges epd.staging.yml + loads .env.staging
|
|
87
|
+
epd deploy -d staging
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
In `epd.staging.yml`:
|
|
91
|
+
```yaml
|
|
92
|
+
# Only specify fields you want to override for staging:
|
|
93
|
+
servers:
|
|
94
|
+
web:
|
|
95
|
+
hosts: [staging-server-ip]
|
|
96
|
+
domains: [staging.example.com]
|
|
97
|
+
|
|
98
|
+
env:
|
|
99
|
+
clear:
|
|
100
|
+
NODE_ENV: staging
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Next Steps
|
|
106
|
+
|
|
107
|
+
- Set up **[Persistent Accessories & Databases](/guide/accessories)**
|
|
108
|
+
- Automate in CI/CD with **[GitHub Actions](/ci-cd)**
|
|
109
|
+
- Review the **[CLI Commands Reference](/reference/cli)**
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Operations & Troubleshooting
|
|
2
|
+
|
|
3
|
+
Practical diagnosis, log inspection, lock release, and recovery procedures for `epd`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Deployment Fails on Health Probe
|
|
8
|
+
|
|
9
|
+
### Symptom:
|
|
10
|
+
```
|
|
11
|
+
✖ Health check failed on 203.0.113.10: replica did not become healthy within 60s.
|
|
12
|
+
Rolling back to live slot...
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Explanation:
|
|
16
|
+
The new version was booted in the idle slot, but requests to `healthcheck.path` (default: `/`) did not return an HTTP status in `200-399` before timing out.
|
|
17
|
+
|
|
18
|
+
### Diagnostic Steps:
|
|
19
|
+
1. **Inspect container crash logs**:
|
|
20
|
+
```bash
|
|
21
|
+
epd logs --service web --lines 100
|
|
22
|
+
```
|
|
23
|
+
2. **Verify application startup speed**:
|
|
24
|
+
If your app takes 45 seconds to compile assets or connect to a database on cold start, increase the timeout in `epd.yml`:
|
|
25
|
+
```yaml
|
|
26
|
+
healthcheck:
|
|
27
|
+
path: /health
|
|
28
|
+
timeout: 90
|
|
29
|
+
delay: 5
|
|
30
|
+
```
|
|
31
|
+
3. **Verify port binding**:
|
|
32
|
+
Ensure your app listens on the port configured under `servers.<service>.port` (e.g. `3000`), and binds to `0.0.0.0` (not `127.0.0.1` inside Docker).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. Deployment Lock is Held
|
|
37
|
+
|
|
38
|
+
### Symptom:
|
|
39
|
+
```
|
|
40
|
+
✖ Another deployment is currently in progress (lock held by deployer-laptop at 14:22).
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Explanation:
|
|
44
|
+
`epd` uses an atomic lock file (`/var/lib/epd/locks/<app>.lock`) to prevent concurrent deployments from colliding. If your computer lost internet connection or was killed with `kill -9` mid-deployment, the lock might remain active.
|
|
45
|
+
|
|
46
|
+
### Solution:
|
|
47
|
+
```bash
|
|
48
|
+
# Check lock details:
|
|
49
|
+
epd lock status
|
|
50
|
+
|
|
51
|
+
# Forcefully clear the lock:
|
|
52
|
+
epd lock release
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 3. Investigating the Shared Traefik Proxy
|
|
58
|
+
|
|
59
|
+
If domains are not resolving or returning `404 page not found`:
|
|
60
|
+
|
|
61
|
+
### Check Proxy Status:
|
|
62
|
+
```bash
|
|
63
|
+
epd proxy status
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### View Live Traefik Logs:
|
|
67
|
+
```bash
|
|
68
|
+
epd proxy logs -f
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Inspect Generated Dynamic Routing YAML:
|
|
72
|
+
```bash
|
|
73
|
+
epd proxy routes
|
|
74
|
+
```
|
|
75
|
+
Verify that your domains, ports, and entrypoints match what you declared in `epd.yml`.
|
|
76
|
+
|
|
77
|
+
### Reboot Traefik:
|
|
78
|
+
If Traefik needs a restart:
|
|
79
|
+
```bash
|
|
80
|
+
epd proxy reboot
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 4. Disaster Recovery & Emergency Rollback
|
|
86
|
+
|
|
87
|
+
To immediately revert to the previously working build:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
epd rollback
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
To list all past deployments saved on the server:
|
|
94
|
+
```bash
|
|
95
|
+
epd rollback --list
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
And roll back to a specific tagged release:
|
|
99
|
+
```bash
|
|
100
|
+
epd rollback <version>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Next Steps
|
|
106
|
+
|
|
107
|
+
- Explore the **[CLI Commands Reference](/reference/cli)**
|
|
108
|
+
- Review the **[Complete epd.yml Schema](/reference/config)**
|
|
109
|
+
- Read the **[GitHub Actions CI/CD Guide](/ci-cd)**
|