@fabioplunser/epd 0.3.0 → 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 +50 -1
- package/dist/cli.js +1248 -486
- package/docs/.vitepress/config.mts +83 -0
- 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 +152 -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 +95 -0
- package/docs/index.md +71 -0
- 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 +6 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Architecture & Concepts
|
|
2
|
+
|
|
3
|
+
Learn how `epd` routes incoming traffic, provides true zero-downtime blue/green switches, and enables multiple independent applications to peacefully share a single host.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## High-Level Request Flow
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Internet (HTTP: 80 / HTTPS: 443)
|
|
11
|
+
│
|
|
12
|
+
▼
|
|
13
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
14
|
+
│ HOST SERVER (e.g. 203.0.113.10) │
|
|
15
|
+
│ │
|
|
16
|
+
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
|
17
|
+
│ │ Shared Traefik Proxy (:80 / :443) │ │
|
|
18
|
+
│ │ Dynamic Config Provider (/var/lib/epd/proxy/dynamic/*.yml) │ │
|
|
19
|
+
│ │ Let's Encrypt ACME Certificate Resolver │ │
|
|
20
|
+
│ └───────────────┬───────────────────────────────┬─────────────────┘ │
|
|
21
|
+
│ │ │ │
|
|
22
|
+
│ Host: blog.example.com Host: store.example.com │
|
|
23
|
+
│ ▼ ▼ │
|
|
24
|
+
│ ┌───────────────────────────────┐ ┌─────────────────────────────┐ │
|
|
25
|
+
│ │ App 1: Blog │ │ App 2: Store │ │
|
|
26
|
+
│ │ Slot: Green (Live) │ │ Slot: Blue (Live) │ │
|
|
27
|
+
│ │ 2 Replicas │ │ 1 Replica │ │
|
|
28
|
+
│ └───────────────┬───────────────┘ └─────────────────────────────┘ │
|
|
29
|
+
│ │ │
|
|
30
|
+
│ ▼ │
|
|
31
|
+
│ ┌───────────────────────────────┐ │
|
|
32
|
+
│ │ Accessory: Postgres │ │
|
|
33
|
+
│ │ /var/lib/epd/volumes/blog-db │ │
|
|
34
|
+
│ └───────────────────────────────┘ │
|
|
35
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Key Principles
|
|
41
|
+
|
|
42
|
+
### 1. Zero Daemons or Control Planes
|
|
43
|
+
Traditional container orchestrators (like Kubernetes, Nomad, or Docker Swarm) require running complex background agents, control planes, and consensus databases.
|
|
44
|
+
|
|
45
|
+
`epd` uses **standard SSH**. When you run `epd deploy`, it connects over SSH, executes necessary Docker/PM2 commands, writes declarative Traefik configuration files, and disconnects. Your servers remain lightweight, predictable, and free of proprietary locks.
|
|
46
|
+
|
|
47
|
+
### 2. The Shared Traefik Reverse Proxy
|
|
48
|
+
Traefik binds to ports 80 and 443 on the host server. Rather than restarting or modifying a master configuration file on every deployment:
|
|
49
|
+
- Traefik watches a dynamic configuration directory: `/var/lib/epd/proxy/dynamic/`.
|
|
50
|
+
- Each deployed app maintains its own file, e.g., `/var/lib/epd/proxy/dynamic/blog.yml`.
|
|
51
|
+
- Traefik hot-reloads routing tables in memory with **zero dropped requests** whenever a file changes.
|
|
52
|
+
- Adding, updating, or deleting one application has zero impact on any other app running on the same server.
|
|
53
|
+
|
|
54
|
+
### 3. Server Filesystem Layout
|
|
55
|
+
|
|
56
|
+
On every server managed by `epd`, files are neatly arranged under `/var/lib/epd`:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/var/lib/epd/
|
|
60
|
+
├── proxy/
|
|
61
|
+
│ ├── traefik.yml # Static Traefik configuration
|
|
62
|
+
│ ├── acme.json # Let's Encrypt SSL certificates (0600)
|
|
63
|
+
│ └── dynamic/ # Traefik hot-reloaded routing directory
|
|
64
|
+
│ ├── app1.yml # App 1 dynamic routing rules
|
|
65
|
+
│ └── app2.yml # App 2 dynamic routing rules
|
|
66
|
+
├── apps/
|
|
67
|
+
│ ├── my-app/
|
|
68
|
+
│ │ ├── env # Secret environment variables (0600)
|
|
69
|
+
│ │ ├── state.json # Active slot, version, and replica state
|
|
70
|
+
│ │ └── releases/ # (Process mode) Versioned releases
|
|
71
|
+
├── volumes/ # Persistent accessory storage (Postgres, Redis)
|
|
72
|
+
└── locks/ # Atomic deployment concurrency locks
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## How epd Compares
|
|
78
|
+
|
|
79
|
+
| Feature | `epd` | Kamal | Kubernetes | Docker Swarm |
|
|
80
|
+
|---|:---:|:---:|:---:|:---:|
|
|
81
|
+
| **Zero-Downtime Blue/Green** | ✅ Built-in | ✅ Rolling | ✅ Complex | ✅ Rolling |
|
|
82
|
+
| **Multi-Site on Single VPS** | ✅ Native (Shared Traefik) | ❌ Port 80/443 conflict | ⚠️ Requires Ingress Controller | ⚠️ Requires Traefik/Nginx |
|
|
83
|
+
| **No-Docker Process Mode (PM2)**| ✅ Built-in | ❌ Docker only | ❌ Containers only | ❌ Containers only |
|
|
84
|
+
| **Hetzner & DNS Automation** | ✅ Built-in | ❌ Third-party | ❌ External operator | ❌ None |
|
|
85
|
+
| **Cross-Host Failover** | ✅ Built-in | ❌ Single host proxy | ✅ Ingress / Mesh | ✅ Ingress routing mesh |
|
|
86
|
+
| **Resource Overhead** | ~30MB (Traefik) | ~50MB | >1GB - 2GB RAM | ~250MB |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Next Steps
|
|
91
|
+
|
|
92
|
+
- Explore the **[Blue/Green Deployment Lifecycle](/guide/blue-green)**
|
|
93
|
+
- Learn about **[Deployment Modes: Docker vs. Process](/guide/deployment-modes)**
|
|
94
|
+
- See how **[Multi-Site Hosting](/guide/multi-site)** works
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Zero-Downtime Blue/Green Deployments
|
|
2
|
+
|
|
3
|
+
Learn how `epd` ensures that zero live user requests are ever dropped during a deployment or rollback.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Blue/Green Lifecycle
|
|
8
|
+
|
|
9
|
+
Unlike standard container restarts which drop connections while waiting for a new process to boot, `epd` uses alternating **slots** (`blue` and `green`):
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
[1. Build & Ship] Builds image locally or uploads process archive
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
[2. Start Idle Slot] Replicas boot up in the alternate slot (e.g., Green)
|
|
16
|
+
│
|
|
17
|
+
▼
|
|
18
|
+
[3. Health Probe Loop] Probes /health inside the server on each replica
|
|
19
|
+
│ └─► If fails: Green killed, Blue remains untouched!
|
|
20
|
+
▼
|
|
21
|
+
[4. Atomic Traefik Switch] Rewrites /var/lib/epd/proxy/dynamic/<app>.yml
|
|
22
|
+
│ └─► Traefik routes new traffic to Green instantly
|
|
23
|
+
▼
|
|
24
|
+
[5. Connection Draining] Waits drain seconds for in-flight requests to complete
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
[6. Retire Previous Slot] Stops previous Blue slot replicas safely
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 1. Health Probe Verification
|
|
33
|
+
|
|
34
|
+
Before Traefik receives instructions to route traffic to the new version, `epd` probes every replica locally on the host server.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
healthcheck:
|
|
38
|
+
path: /health # HTTP endpoint to probe (default: "/")
|
|
39
|
+
status: 200-399 # Acceptable HTTP status codes (default: 200-399)
|
|
40
|
+
timeout: 45 # Maximum seconds to wait before failing (default: 60)
|
|
41
|
+
interval: 2 # Seconds between consecutive probe attempts
|
|
42
|
+
delay: 2 # Delay in seconds before starting probes
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Safety Guarantee:
|
|
46
|
+
If your new version crashes on boot, fails database migrations, or throws an unhandled exception:
|
|
47
|
+
1. The health probe times out or encounters fatal errors.
|
|
48
|
+
2. `epd` immediately cleans up the new slot.
|
|
49
|
+
3. **The existing slot remains live and serving traffic without interruption.**
|
|
50
|
+
4. No visitors experience an error or outage.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 2. Connection Draining
|
|
55
|
+
|
|
56
|
+
When traffic is switched to the new slot, existing long-lived HTTP requests or WebSockets hitting the old slot need time to finish processing.
|
|
57
|
+
|
|
58
|
+
You can configure the drain period in `epd.yml`:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
servers:
|
|
62
|
+
web:
|
|
63
|
+
hosts: [203.0.113.10]
|
|
64
|
+
drain: 15 # Seconds to wait before stopping the old slot (default: 10)
|
|
65
|
+
stop_timeout: 20 # SIGTERM to SIGKILL grace period for containers
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 3. Instant Rollback
|
|
71
|
+
|
|
72
|
+
Because `epd` preserves previous image releases and dynamic configurations on the host server:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Roll back immediately to the previous slot
|
|
76
|
+
epd rollback
|
|
77
|
+
|
|
78
|
+
# Or list all historical versions on servers:
|
|
79
|
+
epd rollback --list
|
|
80
|
+
|
|
81
|
+
# Roll back to a specific past version:
|
|
82
|
+
epd rollback v1.4.2
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Rolling back does not require rebuilding or re-uploading your application code. `epd` spins up the previous version and performs an atomic route switch in under 3 seconds.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Next Steps
|
|
90
|
+
|
|
91
|
+
- Explore **[Multi-Site Hosting on a Single VPS](/guide/multi-site)**
|
|
92
|
+
- Learn about **[High Availability & Clustering](/guide/high-availability)**
|
|
93
|
+
- Configure **[Advanced Routing & Traefik](/guide/routing)**
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Deployment Modes: Docker vs. Process
|
|
2
|
+
|
|
3
|
+
`epd` supports two distinct deployment runtimes configured via the top-level `mode` field: **Docker** and **Process (PM2)**.
|
|
4
|
+
|
|
5
|
+
Both modes share the exact same blue/green zero-downtime guarantees, Traefik SSL routing, health checks, and instant rollbacks.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Comparison
|
|
10
|
+
|
|
11
|
+
| Feature | Docker Mode (`mode: docker`) | Process Mode (`mode: process`) |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| **Best For** | Multi-language apps, containers, microservices | Ultra-low RAM VPS, Bun/Node/Python apps |
|
|
14
|
+
| **Server Requirements** | Docker Engine installed | Node.js/Bun, PM2, and `rsync` |
|
|
15
|
+
| **Container Overhead** | Minimal (~20-40MB per container) | **Zero container overhead** |
|
|
16
|
+
| **Build Location** | Local machine or CI runner | Remote server (or pre-built artifact) |
|
|
17
|
+
| **Image Registry** | Optional (can stream over SSH) | None needed |
|
|
18
|
+
| **Process Manager** | Docker Engine daemon | PM2 process supervisor |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 1. Docker Mode (Default)
|
|
23
|
+
|
|
24
|
+
In Docker mode, your application is packaged as an OCI/Docker container image.
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
name: my-app
|
|
28
|
+
mode: docker
|
|
29
|
+
image: ghcr.io/my-org/my-app
|
|
30
|
+
|
|
31
|
+
servers:
|
|
32
|
+
web:
|
|
33
|
+
hosts: [203.0.113.10]
|
|
34
|
+
port: 3000
|
|
35
|
+
domains: [app.example.com]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### How It Works:
|
|
39
|
+
1. `epd` builds an image locally (using BuildKit / buildx) tagged with the current commit SHA.
|
|
40
|
+
2. **Registry or SSH Stream**:
|
|
41
|
+
- If `registry:` is specified, `epd` pushes the image to your registry (e.g. GitHub Packages or Docker Hub), and servers pull it.
|
|
42
|
+
- If no registry is specified, `epd` streams the image directly to each server over SSH using `docker save | gzip | ssh ... docker load`.
|
|
43
|
+
3. Containers run on a shared Docker bridge network (`epd`).
|
|
44
|
+
4. Replicas communicate with Traefik using internal container names:
|
|
45
|
+
`http://epd-<app>-<service>-<slot>-<replica>:<port>`
|
|
46
|
+
|
|
47
|
+
### Custom Docker Build Configuration
|
|
48
|
+
```yaml
|
|
49
|
+
build:
|
|
50
|
+
dockerfile: docker/Dockerfile.prod
|
|
51
|
+
context: .
|
|
52
|
+
platform: linux/amd64
|
|
53
|
+
args:
|
|
54
|
+
NODE_ENV: production
|
|
55
|
+
API_URL: https://api.example.com
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 2. Process Mode (No Docker on Server)
|
|
61
|
+
|
|
62
|
+
If you don't want or can't run Docker on your servers (for example, on a tiny 512MB or 1GB VPS), `mode: process` runs your code natively using **PM2**.
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
name: my-app
|
|
66
|
+
mode: process
|
|
67
|
+
|
|
68
|
+
process:
|
|
69
|
+
install: bun install --frozen-lockfile
|
|
70
|
+
build: bun run build
|
|
71
|
+
start: bun run start
|
|
72
|
+
exclude:
|
|
73
|
+
- ".git"
|
|
74
|
+
- "node_modules"
|
|
75
|
+
- ".env"
|
|
76
|
+
- "dist"
|
|
77
|
+
- "*.log"
|
|
78
|
+
|
|
79
|
+
servers:
|
|
80
|
+
web:
|
|
81
|
+
hosts: [203.0.113.10]
|
|
82
|
+
replicas: 2
|
|
83
|
+
port: 3000
|
|
84
|
+
domains: [app.example.com]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### How It Works:
|
|
88
|
+
1. `epd` uploads your code via `rsync` into `/var/lib/epd/apps/<app>/releases/<version>/`.
|
|
89
|
+
2. Runs the `install` and `build` commands directly on the server.
|
|
90
|
+
3. Starts each replica under `pm2` with an assigned unique localhost port (e.g., `20101`, `20102`).
|
|
91
|
+
4. Traefik (running as a native binary managed by PM2) automatically routes traffic from ports 80/443 to the healthy PM2 replica ports.
|
|
92
|
+
|
|
93
|
+
### Runtime Examples
|
|
94
|
+
|
|
95
|
+
::: code-group
|
|
96
|
+
|
|
97
|
+
```yaml [Bun (TypeScript / JavaScript)]
|
|
98
|
+
mode: process
|
|
99
|
+
process:
|
|
100
|
+
install: bun install --frozen-lockfile
|
|
101
|
+
build: bun run build
|
|
102
|
+
start: bun run start
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```yaml [Node.js (Next.js / Express / Fastify)]
|
|
106
|
+
mode: process
|
|
107
|
+
process:
|
|
108
|
+
install: npm ci --omit=dev
|
|
109
|
+
build: npm run build
|
|
110
|
+
start: npm run start
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```yaml [Python (FastAPI / Django / Flask)]
|
|
114
|
+
mode: process
|
|
115
|
+
process:
|
|
116
|
+
install: pip install -r requirements.txt
|
|
117
|
+
start: python -m uvicorn main:app --host 127.0.0.1 --port $PORT
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```yaml [Go (Precompiled Binary)]
|
|
121
|
+
mode: process
|
|
122
|
+
process:
|
|
123
|
+
build: go build -o server .
|
|
124
|
+
start: ./server
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
:::
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Next Steps
|
|
132
|
+
|
|
133
|
+
- Understand the **[Blue/Green Lifecycle](/guide/blue-green)**
|
|
134
|
+
- Read about **[Multi-Site Hosting](/guide/multi-site)**
|
|
135
|
+
- Learn how to manage **[Secrets & Environment](/guide/secrets)**
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Getting Started with EPD
|
|
2
|
+
|
|
3
|
+
Deploy any application to one server or a fleet of servers with zero downtime, automatic Let's Encrypt SSL, and a shared Traefik proxy.
|
|
4
|
+
|
|
5
|
+
This guide will take you from zero to a live production deployment in under 5 minutes.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
Before starting, ensure you have:
|
|
12
|
+
|
|
13
|
+
1. **A Linux Server (VPS)**:
|
|
14
|
+
- Any clean Linux VPS (Ubuntu 22.04/24.04, Debian 11/12, Fedora, Arch, etc.)
|
|
15
|
+
- An open SSH port (22) with root or passwordless `sudo` access.
|
|
16
|
+
- Public ports **80** (HTTP) and **443** (HTTPS) accessible from the internet.
|
|
17
|
+
- A DNS `A` record pointing your domain to the server's public IP address.
|
|
18
|
+
|
|
19
|
+
2. **Local Machine**:
|
|
20
|
+
- [Bun](https://bun.sh) (v1.1+) or [Node.js](https://nodejs.org) (v18+).
|
|
21
|
+
- Standard `ssh` client.
|
|
22
|
+
- Docker installed locally (if deploying in Docker mode).
|
|
23
|
+
|
|
24
|
+
::: tip No Server Yet?
|
|
25
|
+
If you don't have a server, you can provision one in 30 seconds using the built-in [Hetzner Cloud integration](/hetzner-dns):
|
|
26
|
+
```bash
|
|
27
|
+
epd hetzner create my-server --setup
|
|
28
|
+
```
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 1. Install EPD
|
|
34
|
+
|
|
35
|
+
Install `epd` globally using your preferred package manager or download the standalone binary:
|
|
36
|
+
|
|
37
|
+
::: code-group
|
|
38
|
+
|
|
39
|
+
```bash [bun]
|
|
40
|
+
bun install -g @fabioplunser/epd
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```bash [npm]
|
|
44
|
+
npm install -g @fabioplunser/epd
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash [pnpm]
|
|
48
|
+
pnpm add -g @fabioplunser/epd
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash [npx (no install)]
|
|
52
|
+
npx @fabioplunser/epd --help
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash [Standalone Binary (Linux)]
|
|
56
|
+
curl -fsSL https://github.com/FabioPlunser/epd/releases/latest/download/epd-linux-x64 -o /usr/local/bin/epd
|
|
57
|
+
chmod +x /usr/local/bin/epd
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
:::
|
|
61
|
+
|
|
62
|
+
Verify installation:
|
|
63
|
+
```bash
|
|
64
|
+
epd --version
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 2. Initialize Your Project
|
|
70
|
+
|
|
71
|
+
Navigate to your application's root directory:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cd my-app
|
|
75
|
+
epd init
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`epd init` will inspect your project:
|
|
79
|
+
- Automatically detects your runtime (Node.js, Bun, Python, Go, Ruby, or static).
|
|
80
|
+
- Detects whether you already have a `Dockerfile`.
|
|
81
|
+
- Prompts for your server IP, domain name, and ACME SSL email.
|
|
82
|
+
- Generates a tailored `epd.yml` config file (and an optimized starter `Dockerfile` if needed).
|
|
83
|
+
|
|
84
|
+
::: tip GitHub Actions Starter
|
|
85
|
+
Run `epd init --ci` to also generate a ready-to-run GitHub Actions workflow (`.github/workflows/deploy.yml`).
|
|
86
|
+
:::
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 3. Configure `epd.yml`
|
|
91
|
+
|
|
92
|
+
Open `epd.yml` in your editor. Here is a typical single-server configuration:
|
|
93
|
+
|
|
94
|
+
::: code-group
|
|
95
|
+
|
|
96
|
+
```yaml [Docker Mode (Default)]
|
|
97
|
+
# Application name (used for container naming and routing isolation)
|
|
98
|
+
name: my-app
|
|
99
|
+
mode: docker
|
|
100
|
+
|
|
101
|
+
# Docker image name (built locally, or pulled from registry)
|
|
102
|
+
image: my-app
|
|
103
|
+
|
|
104
|
+
# SSH connection details
|
|
105
|
+
ssh:
|
|
106
|
+
user: root
|
|
107
|
+
|
|
108
|
+
# Server & Routing
|
|
109
|
+
servers:
|
|
110
|
+
web:
|
|
111
|
+
hosts: [203.0.113.10]
|
|
112
|
+
port: 3000
|
|
113
|
+
domains: [app.example.com]
|
|
114
|
+
|
|
115
|
+
# Shared Traefik Proxy & Automatic SSL
|
|
116
|
+
proxy:
|
|
117
|
+
email: admin@example.com
|
|
118
|
+
|
|
119
|
+
# Health check probe before switching live traffic
|
|
120
|
+
healthcheck:
|
|
121
|
+
path: /health
|
|
122
|
+
timeout: 30
|
|
123
|
+
|
|
124
|
+
# Environment variables & secrets
|
|
125
|
+
env:
|
|
126
|
+
clear:
|
|
127
|
+
NODE_ENV: production
|
|
128
|
+
secret:
|
|
129
|
+
- DATABASE_URL
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```yaml [Process Mode (No Docker on Server)]
|
|
133
|
+
# Run code directly under PM2 without Docker on the host
|
|
134
|
+
name: my-app
|
|
135
|
+
mode: process
|
|
136
|
+
|
|
137
|
+
process:
|
|
138
|
+
install: bun install --frozen-lockfile
|
|
139
|
+
build: bun run build
|
|
140
|
+
start: bun run start
|
|
141
|
+
exclude: [".git", "node_modules", ".env", "dist"]
|
|
142
|
+
|
|
143
|
+
ssh:
|
|
144
|
+
user: root
|
|
145
|
+
|
|
146
|
+
servers:
|
|
147
|
+
web:
|
|
148
|
+
hosts: [203.0.113.10]
|
|
149
|
+
replicas: 2
|
|
150
|
+
port: 3000
|
|
151
|
+
domains: [app.example.com]
|
|
152
|
+
|
|
153
|
+
proxy:
|
|
154
|
+
email: admin@example.com
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
:::
|
|
158
|
+
|
|
159
|
+
### Secrets Setup
|
|
160
|
+
|
|
161
|
+
Any secret declared under `env.secret` is resolved automatically from your local shell or `.env` file:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# In your local .env or current shell:
|
|
165
|
+
export DATABASE_URL="postgres://user:password@host/dbname"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
When you deploy, `epd` securely uploads secrets into a root-owned `0600` file on the remote server without saving secrets in git or container image layers.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 4. Run Server Setup
|
|
173
|
+
|
|
174
|
+
Run `epd setup` once for each new server:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
epd setup
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### What `epd setup` does automatically:
|
|
181
|
+
1. **Validates SSH Connectivity** to all configured servers.
|
|
182
|
+
2. **Installs Host Prerequisites**: Installs Docker (or PM2 and Node/Bun in process mode) if not already present.
|
|
183
|
+
3. **Provisions Shared Traefik Reverse Proxy**: Launches Traefik listening on ports 80 and 443 with Let's Encrypt automated ACME SSL certificate issuance.
|
|
184
|
+
4. **Creates Network & Storage**: Configures the shared Docker bridge network (`epd`) and volume directories (`/var/lib/epd`).
|
|
185
|
+
5. **Runs Your First Deployment**: Builds the app, starts the blue slot, verifies health checks, and registers the domain in Traefik.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 5. Deploy Updates with Zero Downtime
|
|
190
|
+
|
|
191
|
+
Whenever you commit changes or want to deploy an update:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
epd deploy
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`epd deploy` executes a zero-downtime blue/green swap:
|
|
198
|
+
1. Builds the latest container image (or syncs process code).
|
|
199
|
+
2. Starts the new version in the **idle slot** (e.g., `green`).
|
|
200
|
+
3. Probes the internal health check endpoint until healthy.
|
|
201
|
+
4. Atomically updates Traefik's dynamic routing to direct incoming requests to the new slot.
|
|
202
|
+
5. Drains in-flight connections to the previous slot (`blue`) before gracefully stopping it.
|
|
203
|
+
|
|
204
|
+
::: tip Rollback Anytime
|
|
205
|
+
If an issue occurs after deployment, revert instantly to the previous version with:
|
|
206
|
+
```bash
|
|
207
|
+
epd rollback
|
|
208
|
+
```
|
|
209
|
+
This re-activates the previous slot in seconds without rebuilding or re-uploading!
|
|
210
|
+
:::
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 6. Inspect & Monitor
|
|
215
|
+
|
|
216
|
+
Use `epd` CLI commands to check your application's health:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Check running containers, active slots, and route status
|
|
220
|
+
epd status
|
|
221
|
+
|
|
222
|
+
# Stream live container logs
|
|
223
|
+
epd logs -f
|
|
224
|
+
|
|
225
|
+
# Follow logs specifically from your web service
|
|
226
|
+
epd logs --service web -f --lines 100
|
|
227
|
+
|
|
228
|
+
# Open an interactive shell inside a running replica
|
|
229
|
+
epd shell
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Next Steps
|
|
235
|
+
|
|
236
|
+
Now that your application is live, explore additional capabilities:
|
|
237
|
+
|
|
238
|
+
- **[Architecture & Concepts](/guide/architecture)**: How Traefik routing, blue/green slots, and failover work.
|
|
239
|
+
- **[Deployment Modes](/guide/deployment-modes)**: Compare Docker vs. Process (PM2) modes.
|
|
240
|
+
- **[Multi-Site Hosting](/guide/multi-site)**: Host 5, 10, or 20 distinct domains on a single VPS.
|
|
241
|
+
- **[Accessories & Databases](/guide/accessories)**: Spin up PostgreSQL, Redis, or MinIO alongside your app.
|
|
242
|
+
- **[GitHub Actions CI/CD](/ci-cd)**: Set up fully automated deployments on every `git push`.
|
|
243
|
+
- **[Hetzner Cloud & DNS](/hetzner-dns)**: Automate server provisioning and Cloudflare/Hetzner DNS sync.
|
|
244
|
+
- **[CLI Reference](/reference/cli)**: Complete list of all CLI commands and flags.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# High Availability & Multi-Server Clustering
|
|
2
|
+
|
|
3
|
+
Scale your application across multiple servers with rolling zero-downtime updates, cross-host load balancing, and private network routing.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Multi-Server Architecture
|
|
8
|
+
|
|
9
|
+
When deploying to multiple hosts, `epd` can either route traffic locally on each server or establish a distributed ingress mesh across all nodes.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
DNS (Round Robin or Cloudflare)
|
|
13
|
+
┌──────────────┴──────────────┐
|
|
14
|
+
│ │
|
|
15
|
+
▼ ▼
|
|
16
|
+
┌───────────────────┐ ┌───────────────────┐
|
|
17
|
+
│ Server 1 (Host A) │ │ Server 2 (Host B) │
|
|
18
|
+
│ Traefik Proxy │◄───────►│ Traefik Proxy │
|
|
19
|
+
│ Replicas (Slot G) │ Private │ Replicas (Slot G) │
|
|
20
|
+
└───────────────────┘ Network └───────────────────┘
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Cross-Host Routing (`proxy.cross_host: true`)
|
|
26
|
+
|
|
27
|
+
By default, Traefik on Server A balances requests only among containers running on Server A.
|
|
28
|
+
|
|
29
|
+
With `proxy.cross_host: true`:
|
|
30
|
+
- Each server's Traefik instance includes upstream replica targets across the **entire cluster**.
|
|
31
|
+
- If Server B experiences hardware failure or is undergoing maintenance, requests arriving at Server B's IP address can be transparently forwarded to healthy containers on Server A.
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
name: my-app
|
|
35
|
+
mode: docker
|
|
36
|
+
image: ghcr.io/my-org/my-app
|
|
37
|
+
|
|
38
|
+
proxy:
|
|
39
|
+
cross_host: true
|
|
40
|
+
# Bind internal service traffic to private VPC network IPs
|
|
41
|
+
private_ips:
|
|
42
|
+
203.0.113.10: 10.0.0.10
|
|
43
|
+
203.0.113.11: 10.0.0.11
|
|
44
|
+
203.0.113.12: 10.0.0.12
|
|
45
|
+
|
|
46
|
+
servers:
|
|
47
|
+
web:
|
|
48
|
+
hosts:
|
|
49
|
+
- 203.0.113.10
|
|
50
|
+
- 203.0.113.11
|
|
51
|
+
- 203.0.113.12
|
|
52
|
+
replicas: 2
|
|
53
|
+
port: 3000
|
|
54
|
+
domains: [app.example.com]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 2. Deployment Strategies: Rolling vs. Parallel
|
|
60
|
+
|
|
61
|
+
When deploying updates to a multi-server cluster, `epd` controls the rollout strategy:
|
|
62
|
+
|
|
63
|
+
### Rolling Deployment (Default)
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
strategy: rolling
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
In a rolling deployment:
|
|
70
|
+
1. `epd` deploys to Host 1 and waits until health probes pass.
|
|
71
|
+
2. Once Host 1 is live and serving new traffic, it moves to Host 2.
|
|
72
|
+
3. This sequence repeats until the entire fleet is updated.
|
|
73
|
+
4. If a failure occurs on Host 2, Host 1 is already healthy, and the deployment stops safely before breaking the remaining hosts.
|
|
74
|
+
|
|
75
|
+
### Parallel Deployment
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
strategy: parallel
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Deploys to all configured hosts concurrently. Recommended for staging environments or non-critical worker clusters where deploy speed is prioritized.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Next Steps
|
|
86
|
+
|
|
87
|
+
- Set up **[Automated Multi-Provider DNS Synchronization](/hetzner-dns)**
|
|
88
|
+
- Configure **[Advanced Routing Rules](/guide/routing)**
|
|
89
|
+
- Check out the **[Complete Configuration Schema](/reference/config)**
|