@fabioplunser/epd 0.5.18 → 0.5.19

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.
@@ -1,296 +0,0 @@
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 (or password to allow EPD to configure it).
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
- - Linux or macOS (or Windows via WSL2).
21
- - Standard `ssh` client.
22
- - Docker installed locally (if deploying in Docker mode to build images).
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` using the zero-dependency standalone installer (requires no Node.js or Bun runtime), or via your favorite package manager:
36
-
37
- ::: code-group
38
-
39
- ```bash [curl (Zero Dependencies)]
40
- curl -fsSL https://raw.githubusercontent.com/FabioPlunser/epd/main/install.sh | bash
41
- ```
42
-
43
- ```bash [bun]
44
- bun install -g @fabioplunser/epd
45
- ```
46
-
47
- ```bash [npm]
48
- npm install -g @fabioplunser/epd
49
- ```
50
-
51
- ```bash [pnpm]
52
- pnpm add -g @fabioplunser/epd
53
- ```
54
-
55
- ```bash [npx (no install)]
56
- npx @fabioplunser/epd --help
57
- ```
58
-
59
- :::
60
-
61
- Verify installation:
62
- ```bash
63
- epd --version
64
- ```
65
-
66
- ---
67
-
68
- ## 2. Shell Autocompletion (Optional)
69
-
70
- Enable instant tab-completion for all commands, flags, and destination overlays:
71
-
72
- ::: code-group
73
-
74
- ```bash [zsh]
75
- eval "$(epd completion zsh)"
76
- ```
77
-
78
- ```bash [bash]
79
- source <(epd completion bash)
80
- ```
81
-
82
- ```bash [fish]
83
- epd completion fish | source
84
- ```
85
-
86
- :::
87
-
88
- ---
89
-
90
- ## 3. Initialize Your Project
91
-
92
- Navigate to your application's root directory:
93
-
94
- ```bash
95
- cd my-app
96
- epd init
97
- ```
98
-
99
- `epd init` will inspect your project:
100
- - Automatically detects your runtime (Node.js, Bun, Python, Go, Ruby, or static).
101
- - Detects whether you already have a `Dockerfile`.
102
- - Prompts for your server IP, domain name, and ACME SSL email.
103
- - Generates a tailored `epd.yml` config file (and an optimized starter `Dockerfile` if needed).
104
-
105
- ::: tip GitHub Actions Starter
106
- Run `epd init --ci` or `epd gh-action` to also generate a ready-to-run GitHub Actions workflow (`.github/workflows/deploy.yml`).
107
- :::
108
-
109
- ---
110
-
111
- ## 4. Configure `epd.yml`
112
-
113
- Open `epd.yml` in your editor. Here is a typical single-server configuration:
114
-
115
- ::: code-group
116
-
117
- ```yaml [Docker Mode (Default)]
118
- # Application name (used for container naming and routing isolation)
119
- name: my-app
120
- mode: docker
121
-
122
- # Docker image name (built locally, or pulled from registry)
123
- image: my-app
124
-
125
- # SSH connection details
126
- ssh:
127
- user: root
128
-
129
- # Server & Routing
130
- servers:
131
- web:
132
- hosts: [203.0.113.10]
133
- port: 3000
134
- domains: [app.example.com]
135
-
136
- # Shared Traefik Proxy & Automatic SSL
137
- proxy:
138
- email: admin@example.com
139
-
140
- # Health check probe before switching live traffic
141
- healthcheck:
142
- path: /health
143
- timeout: 30
144
-
145
- # Environment variables & secrets
146
- env:
147
- clear:
148
- NODE_ENV: production
149
- secret:
150
- - DATABASE_URL
151
- ```
152
-
153
- ```yaml [Process Mode (No Docker on Server)]
154
- # Run code directly under PM2 without Docker on the host
155
- name: my-app
156
- mode: process
157
-
158
- process:
159
- install: bun install --frozen-lockfile
160
- build: bun run build
161
- start: bun run start
162
- exclude: [".git", "node_modules", ".env", "dist"]
163
-
164
- ssh:
165
- user: root
166
-
167
- servers:
168
- web:
169
- hosts: [203.0.113.10]
170
- replicas: 2
171
- port: 3000
172
- domains: [app.example.com]
173
-
174
- proxy:
175
- email: admin@example.com
176
- ```
177
-
178
- :::
179
-
180
- ### Secrets Setup
181
-
182
- Any secret declared under `env.secret` is resolved automatically from your local shell or `.env` file:
183
-
184
- ```bash
185
- # In your local .env or current shell:
186
- export DATABASE_URL="postgres://user:password@host/dbname"
187
- ```
188
-
189
- 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.
190
-
191
- ---
192
-
193
- ## 5. Pre-flight Checks (`epd doctor`)
194
-
195
- Run `epd doctor` to verify your local tools, secrets, and server reachability before deploying:
196
-
197
- ```bash
198
- epd doctor
199
- ```
200
-
201
- `epd doctor` confirms:
202
- - Local Bun/Node, Docker engine, and clean git state
203
- - SSH client and key permissions (`0600`)
204
- - `epd.yml` syntax and `.env` secret availability
205
- - Remote server SSH reachability, passwordless sudo, Docker health, and free disk space
206
-
207
- ---
208
-
209
- ## 6. Run Server Setup
210
-
211
- Run `epd setup` once for each new server:
212
-
213
- ```bash
214
- epd setup
215
- ```
216
-
217
- ### Automated SSH & Server Onboarding:
218
- - **Password Prompt**: If your server only has password login enabled, `epd setup` prompts for the server password once.
219
- - **Key Installation**: It installs your public key (`~/.ssh/id_ed25519.pub`) to `~/.ssh/authorized_keys`.
220
- - **Passwordless Sudo**: Configures `/etc/sudoers.d/epd` automatically so future commands run non-interactively.
221
- - **Docker & Traefik**: Installs Docker and starts Traefik reverse proxy with Let's Encrypt SSL.
222
- - **Initial Deploy**: Builds your image, boots slot `blue`, verifies health checks, and registers routes.
223
-
224
- ---
225
-
226
- ## 7. Deploy Updates with Zero Downtime
227
-
228
- Whenever you commit changes or want to deploy an update:
229
-
230
- ```bash
231
- epd deploy
232
- ```
233
-
234
- Want to preview the deployment plan without changing anything on the servers? Run a dry run:
235
- ```bash
236
- epd deploy --dry-run
237
- ```
238
-
239
- `epd deploy` executes a zero-downtime blue/green swap:
240
- 1. Builds the latest container image (or syncs process code).
241
- 2. Starts the new version in the **idle slot** (e.g., `green`).
242
- 3. Probes the internal health check endpoint until healthy.
243
- 4. Atomically updates Traefik's dynamic routing to direct incoming requests to the new slot.
244
- 5. Drains in-flight connections to the previous slot (`blue`) before gracefully stopping it.
245
-
246
- ::: tip Rollback Anytime
247
- If an issue occurs after deployment, revert instantly to the previous version with:
248
- ```bash
249
- epd rollback
250
- ```
251
- This re-activates the previous slot in seconds without rebuilding or re-uploading!
252
- :::
253
-
254
- ---
255
-
256
- ## 8. Inspect & Monitor
257
-
258
- Use `epd` CLI commands to check your application's health and operations:
259
-
260
- ```bash
261
- # Check running containers, active slots, and route status
262
- epd status
263
-
264
- # Stream live container logs
265
- epd logs -f
266
-
267
- # Real-time multi-server CPU, memory, and container monitor
268
- epd top
269
-
270
- # Inspect Let's Encrypt SSL/TLS certificates and days to expiry
271
- epd ssl
272
-
273
- # Toggle zero-downtime 503 maintenance page
274
- epd maintenance on -m "Upgrading database. Back in 10 minutes."
275
- epd maintenance off
276
-
277
- # Create compressed database / volume backups
278
- epd backup db
279
-
280
- # Open an interactive shell inside a running replica
281
- epd shell
282
- ```
283
-
284
- ---
285
-
286
- ## Next Steps
287
-
288
- Now that your application is live, explore additional capabilities:
289
-
290
- - **[Architecture & Concepts](/guide/architecture)**: How Traefik routing, blue/green slots, and failover work.
291
- - **[Deployment Modes](/guide/deployment-modes)**: Compare Docker vs. Process (PM2) modes.
292
- - **[Multi-Site Hosting](/guide/multi-site)**: Host 5, 10, or 20 distinct domains on a single VPS.
293
- - **[Accessories & Databases](/guide/accessories)**: Spin up PostgreSQL, Redis, or MinIO alongside your app.
294
- - **[GitHub Actions CI/CD](/ci-cd)**: Set up fully automated deployments on every `git push`.
295
- - **[Hetzner Cloud & DNS](/hetzner-dns)**: Automate server provisioning and Cloudflare/Hetzner DNS sync.
296
- - **[CLI Reference](/reference/cli)**: Complete list of all CLI commands and flags.
@@ -1,103 +0,0 @@
1
- # Accessories (Databases, Caches & Dashboards)
2
-
3
- Learn how to provision and manage stateful companion services like PostgreSQL, Redis, MinIO, and Adminer alongside your application.
4
-
5
- ---
6
-
7
- ## What Are Accessories?
8
-
9
- Unlike application containers (which are replaced on every deploy to enable zero-downtime blue/green switches), **accessories** are long-lived, persistent containers:
10
-
11
- - **Stateful Storage**: Data is preserved across deployments using Docker host volumes.
12
- - **Dedicated Lifecycle**: Accessories are started once and remain running when you deploy code updates.
13
- - **Optional Traefik Ingress**: Accessories can have their own public domains and SSL certificates (great for web-based DB managers like Adminer).
14
-
15
- ---
16
-
17
- ## Configuring Accessories in `epd.yml`
18
-
19
- ```yaml
20
- accessories:
21
- # 1. PostgreSQL Database
22
- db:
23
- image: postgres:17-alpine
24
- host: 203.0.113.10
25
- env:
26
- clear:
27
- POSTGRES_DB: myapp
28
- POSTGRES_USER: postgres
29
- secret:
30
- - POSTGRES_PASSWORD
31
- volumes:
32
- - /var/lib/epd/volumes/myapp-postgres:/var/lib/postgresql/data
33
- ports:
34
- - "127.0.0.1:5432:5432" # Bound strictly to localhost for safety
35
-
36
- # 2. Redis Cache
37
- redis:
38
- image: redis:7-alpine
39
- host: 203.0.113.10
40
- volumes:
41
- - /var/lib/epd/volumes/myapp-redis:/data
42
- command: redis-server --appendonly yes
43
-
44
- # 3. Database Management UI (Public HTTPS via Traefik)
45
- db_ui:
46
- image: adminer:latest
47
- host: 203.0.113.10
48
- port: 8080
49
- domains: [db.myapp.example.com]
50
- ```
51
-
52
- ---
53
-
54
- ## Inter-Container Networking
55
-
56
- In Docker mode, application containers and accessory containers run on the shared `epd` Docker network.
57
-
58
- Your application can reach accessories using their container name directly:
59
- ```
60
- postgres://postgres:${POSTGRES_PASSWORD}@epd-myapp-accessory-db:5432/myapp
61
- redis://epd-myapp-accessory-redis:6379
62
- ```
63
-
64
- ---
65
-
66
- ## Managing Accessories via CLI
67
-
68
- `epd` includes specialized CLI commands for working with accessories:
69
-
70
- ### Inspect Status
71
- ```bash
72
- epd status
73
- ```
74
- Shows running accessories, image tags, port mappings, and container health.
75
-
76
- ### View Accessory Logs
77
- ```bash
78
- # Follow live logs from the postgres database
79
- epd logs --accessory db -f
80
- ```
81
-
82
- ### Run Commands Inside an Accessory
83
- ```bash
84
- # Open an interactive psql session inside the database container
85
- epd exec --accessory db -i -- psql -U postgres -d myapp
86
-
87
- # Run a Redis CLI ping
88
- epd exec --accessory redis -- redis-cli ping
89
- ```
90
-
91
- ### Recreate Accessories
92
- If you update an accessory's image tag, environment variable, or volume configuration:
93
- ```bash
94
- epd deploy --recreate-accessories
95
- ```
96
-
97
- ---
98
-
99
- ## Next Steps
100
-
101
- - Explore **[Operations & Troubleshooting](/guide/troubleshooting)**
102
- - Learn about **[Automating with GitHub Actions](/ci-cd)**
103
- - View the full **[CLI Reference](/reference/cli)**
@@ -1,94 +0,0 @@
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
@@ -1,93 +0,0 @@
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)**