@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.
@@ -0,0 +1,127 @@
1
+ # Prerequisites & Installation
2
+
3
+ Everything you need to prepare your development environment and target servers for `epd`.
4
+
5
+ ---
6
+
7
+ ## Local System Requirements
8
+
9
+ `epd` runs on your local development machine or inside a CI runner (such as GitHub Actions).
10
+
11
+ - **Operating System**: macOS, Linux, or Windows (via WSL2).
12
+ - **Runtime**:
13
+ - [Bun](https://bun.sh) v1.1.0 or higher *(recommended)*, OR
14
+ - [Node.js](https://nodejs.org) v18.0.0 or higher.
15
+ - **Tools**:
16
+ - OpenSSH client (`ssh`).
17
+ - Docker Desktop or Docker Engine (required if using `mode: docker`).
18
+ - `rsync` (required if using `mode: process`).
19
+
20
+ ---
21
+
22
+ ## Server Requirements
23
+
24
+ `epd` communicates over standard SSH. No custom agent daemons or background control planes need to run on the server.
25
+
26
+ - **Operating System**: Any 64-bit Linux distribution:
27
+ - Ubuntu 20.04 / 22.04 / 24.04 LTS *(recommended)*
28
+ - Debian 11 / 12
29
+ - Fedora 39+ / AlmaLinux / Rocky Linux
30
+ - Arch Linux / Alpine Linux
31
+ - **SSH Access**:
32
+ - Open SSH port (default: 22).
33
+ - User with `root` privileges or passwordless `sudo`.
34
+ - SSH public key authentication configured.
35
+ - **Firewall & Ports**:
36
+ - **Port 80 (HTTP)**: Required for Let's Encrypt HTTP-01 challenge and HTTP traffic redirection.
37
+ - **Port 443 (HTTPS)**: Required for encrypted TLS/SSL traffic.
38
+ - **Port 22 (SSH)**: Required for deployment and server management.
39
+
40
+ ::: tip Automatic Server Provisioning
41
+ `epd setup` automatically installs Docker, Traefik, curl, and necessary host utilities. You only need a clean server with SSH access!
42
+ :::
43
+
44
+ ---
45
+
46
+ ## Installing EPD
47
+
48
+ ### Option 1: Bun (Recommended)
49
+
50
+ ```bash
51
+ bun install -g @fabioplunser/epd
52
+ ```
53
+
54
+ ### Option 2: NPM / PNPM / Yarn
55
+
56
+ ::: code-group
57
+
58
+ ```bash [npm]
59
+ npm install -g @fabioplunser/epd
60
+ ```
61
+
62
+ ```bash [pnpm]
63
+ pnpm add -g @fabioplunser/epd
64
+ ```
65
+
66
+ ```bash [yarn]
67
+ yarn global add @fabioplunser/epd
68
+ ```
69
+
70
+ :::
71
+
72
+ ### Option 3: Standalone Linux Binary (No Node/Bun Required)
73
+
74
+ If you are running in CI or want a single standalone binary:
75
+
76
+ ```bash
77
+ curl -fsSL https://github.com/FabioPlunser/epd/releases/latest/download/epd-linux-x64 -o /usr/local/bin/epd
78
+ chmod +x /usr/local/bin/epd
79
+ ```
80
+
81
+ ### Option 4: Run via `npx` / `bunx` Without Installation
82
+
83
+ ```bash
84
+ npx @fabioplunser/epd deploy
85
+ # or
86
+ bunx @fabioplunser/epd deploy
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Configuring SSH Access
92
+
93
+ `epd` connects to servers using your system's SSH configuration.
94
+
95
+ ### 1. Test Direct Connection
96
+
97
+ Before running `epd setup`, verify you can connect without entering a password:
98
+
99
+ ```bash
100
+ ssh root@203.0.113.10
101
+ ```
102
+
103
+ ### 2. Copy SSH Key to Server
104
+
105
+ If you need to copy your local SSH key to the remote server:
106
+
107
+ ```bash
108
+ ssh-copy-id root@203.0.113.10
109
+ ```
110
+
111
+ ### 3. Custom SSH Keys & Ports
112
+
113
+ If your server uses a non-standard port or specific key, specify them in `epd.yml`:
114
+
115
+ ```yaml
116
+ ssh:
117
+ user: ubuntu
118
+ port: 2222
119
+ key: ~/.ssh/id_ed25519
120
+ proxy_jump: bastion.example.com
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Next Step
126
+
127
+ Once prerequisites are in place, proceed to the **[Getting Started Guide](/guide/getting-started)** or explore the **[Architecture & Flow](/guide/architecture)**.
@@ -0,0 +1,101 @@
1
+ # Multi-Site Hosting on a Single VPS
2
+
3
+ Learn how `epd` lets you run multiple independent applications on a single $5 VPS without port collisions, conflicting SSL certificates, or downtime.
4
+
5
+ ---
6
+
7
+ ## The Problem with Other Deployment Tools
8
+
9
+ Many deployment tools (like Kamal or basic Docker Compose setups) assume that one application owns the host's ports 80 and 443.
10
+
11
+ When you try to deploy a second application on the same machine:
12
+ - The second proxy container fails to bind to port 80/443.
13
+ - Or you have to manually configure an external Nginx or Traefik reverse proxy outside of your deployment tooling.
14
+ - SSL certificates for different domains collide.
15
+
16
+ ---
17
+
18
+ ## How EPD Solves Multi-Site Hosting
19
+
20
+ `epd` provisions a **single, shared Traefik proxy** on the host. Every application deployed with `epd` writes its own isolated dynamic routing file:
21
+
22
+ ```
23
+ /var/lib/epd/proxy/dynamic/
24
+ ├── blog.yml # Managed by App 1 (blog.example.com)
25
+ ├── store.yml # Managed by App 2 (store.example.com)
26
+ └── docs.yml # Managed by App 3 (docs.example.com)
27
+ ```
28
+
29
+ Each app specifies its own domains and routes in its own `epd.yml`. When you deploy `blog`:
30
+ 1. `epd` only updates `/var/lib/epd/proxy/dynamic/blog.yml`.
31
+ 2. Traefik hot-reloads the changes in milliseconds.
32
+ 3. `store` and `docs` remain completely unaffected!
33
+
34
+ ---
35
+
36
+ ## Example: Deploying Two Apps to One Server
37
+
38
+ ### App 1: Blog (`epd.yml`)
39
+
40
+ ```yaml
41
+ name: blog
42
+ mode: docker
43
+ image: my-dockerhub-user/blog
44
+
45
+ servers:
46
+ web:
47
+ hosts: [203.0.113.10]
48
+ port: 3000
49
+ domains: [blog.example.com]
50
+
51
+ proxy:
52
+ email: admin@example.com
53
+ ```
54
+
55
+ ### App 2: Store (`epd.yml`)
56
+
57
+ ```yaml
58
+ name: store
59
+ mode: process
60
+
61
+ process:
62
+ install: bun install
63
+ build: bun run build
64
+ start: bun run start
65
+
66
+ servers:
67
+ web:
68
+ hosts: [203.0.113.10]
69
+ port: 4000
70
+ domains: [store.example.com]
71
+
72
+ proxy:
73
+ email: admin@example.com
74
+ ```
75
+
76
+ Both apps can be deployed, updated, or rolled back independently.
77
+
78
+ ---
79
+
80
+ ## Isolated Decommissioning
81
+
82
+ If you ever want to permanently decommission an app:
83
+
84
+ ```bash
85
+ cd my-store-repo
86
+ epd remove
87
+ ```
88
+
89
+ `epd remove`:
90
+ - Stops and removes all containers or PM2 processes for `store`.
91
+ - Deletes `/var/lib/epd/proxy/dynamic/store.yml`.
92
+ - Traefik ceases routing traffic for `store.example.com`.
93
+ - **`blog` and all other applications continue running without interruption.**
94
+
95
+ ---
96
+
97
+ ## Next Steps
98
+
99
+ - Explore **[Advanced Routing & Traefik Features](/guide/routing)**
100
+ - Configure **[Persistent Accessories & Databases](/guide/accessories)**
101
+ - Learn how to scale across multiple nodes with **[High Availability](/guide/high-availability)**
@@ -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)**