@fabioplunser/epd 0.5.14 → 0.5.16

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.
@@ -57,6 +57,8 @@ export default defineConfig({
57
57
  { text: "High Availability", link: "/guide/high-availability" },
58
58
  { text: "Multi-Site Hosting", link: "/guide/multi-site" },
59
59
  { text: "Secrets Management", link: "/guide/secrets" },
60
+ { text: "Private Repository Connections", link: "/guide/private-repositories" },
61
+ { text: "Server Security Baseline", link: "/guide/server-baseline" },
60
62
  { text: "Troubleshooting", link: "/guide/troubleshooting" },
61
63
  ],
62
64
  },
package/docs/agents.md CHANGED
@@ -1,4 +1,19 @@
1
- # AI Agents Guide (Autonomous Deployments)
1
+ # AI agent guide
2
+
3
+ The installed CLI includes a setup guide. Run `epd agent --guide` to read it,
4
+ or `epd agent --write-guide EPD_AGENT.md` to export it without overwriting a file.
5
+ `epd agent` launches an installed Codex or Claude CLI with that guide and a setup
6
+ task. `--cli <executable>` selects another CLI that accepts a positional prompt.
7
+ The agent keeps its normal permissions and asks before provisioning or deploying.
8
+ Both `epd` and `edp` are supported command names.
9
+
10
+ `epd init` starts the full configuration wizard in a terminal. Use `--yes` and
11
+ explicit flags for scripts. Set `container_engine: auto`, `podman`, `docker`,
12
+ `nerdctl` or a custom Docker-compatible executable in `epd.yml`.
13
+ `EPD_CONTAINER_ENGINE` overrides the YAML value. This selects the local engine;
14
+ remote servers still use Docker. Use the bundled guide and installed command
15
+ help as the reference for the current CLI version.
16
+
2
17
 
3
18
  > How AI coding agents (Cursor, Windsurf, Claude Code, Cline, Roo, Copilot, Antigravity) use EPD to provision servers and deploy applications autonomously.
4
19
 
package/docs/ci-cd.md CHANGED
@@ -98,7 +98,7 @@ image: ghcr.io/${{ github.repository }}/app
98
98
  registry:
99
99
  server: ghcr.io
100
100
  username: ${{ github.actor }}
101
- password_env: GITHUB_TOKEN
101
+ password: GITHUB_TOKEN
102
102
  ```
103
103
 
104
104
  In `.github/workflows/deploy.yml`:
@@ -0,0 +1,181 @@
1
+ # Dashboard validation
2
+
3
+ The local unit/contract suites and a production build are useful checks, but do
4
+ not prove that SSH deployment, server startup after reboot, or provider
5
+ authentication works. Keep those results separate in `log.md`.
6
+
7
+ ## Portable checks
8
+
9
+ ```sh
10
+ bun install --frozen-lockfile
11
+ bun run typecheck
12
+ bun test
13
+ bun run web:check
14
+ bun run web:build:verify
15
+ bun run web:bundles
16
+ ```
17
+
18
+ The Bash health-probe, fake OpenSSH transport and retention-entrypoint fixtures
19
+ execute POSIX programs locally. They are explicitly skipped on Windows and run
20
+ on the appropriate Linux/macOS CI jobs. Logging subprocess tests are portable.
21
+ Windows still runs dashboard authorization, database, storage transport,
22
+ OAuth/Git credential, job-recovery and SSE regression tests.
23
+
24
+ The build-isolation wrapper checks that route analysis does not create or modify
25
+ the configured runtime database paths. Bundle measurements are a cold-cache
26
+ estimate, not a Lighthouse score. Set `EPD_MAX_ROUTE_JS_GZIP_KB` to enforce an
27
+ explicit measured route budget; no unmeasured 100 KB claim is made.
28
+
29
+ The isolated Linux helper verifies a complete source/test inventory before
30
+ running tests, and refuses to build a stale saved snapshot:
31
+
32
+ ```sh
33
+ bash scripts/validate-linux.sh
34
+ bash scripts/validate-linux.sh --build-existing /tmp/epd-linux-validation.REPORTED_ID
35
+ ```
36
+
37
+ The first command prints its actual temporary directory. The second resumes
38
+ that directory only when its source and tests still match the workspace. Start
39
+ a fresh run after changing source. Local environment files and logs are excluded
40
+ from the copied tree.
41
+
42
+ ## Docker on Windows
43
+
44
+ Start Docker Desktop with its Linux engine and confirm `docker info` succeeds.
45
+ Run the Linux shell harnesses from a Linux environment, such as an integrated
46
+ WSL distribution. Use a copy of the **current working tree**: cloning the remote
47
+ repository will omit uncommitted implementation changes. Install Linux
48
+ dependencies in that copy; do not reuse Windows `node_modules` links.
49
+
50
+ ```sh
51
+ bun run web:test:e2e
52
+ bun scripts/alloy-config-e2e.ts
53
+ sh deploy/console/test/run.sh
54
+ bash deploy/console/test/features-e2e.sh
55
+ ```
56
+
57
+ The deployment harness creates a uniquely named privileged Docker-in-Docker
58
+ fixture. Its nested Docker daemon isolates EPD's proxy/container names from
59
+ normal host workloads. The fixture is disposable, with scoped cleanup and
60
+ diagnostics in `test-results/`. Read `test/web-e2e/README.md` for scenario details.
61
+
62
+ For credential-free local S3 authentication and PostgreSQL restoration through
63
+ stored objects, follow [local S3 wire validation](storage-validation.md). This
64
+ uses a signature-validating disposable server and the actual storage adapter.
65
+
66
+ A container restart is not a real machine reboot. Container tests do not close
67
+ the reboot validation item.
68
+
69
+ ## Disposable VM and reboot validation
70
+
71
+ An Ubuntu Server 24.04 Hyper-V VM is suitable. A suggested small test allocation
72
+ is 2 vCPUs, 4 GB RAM and a 30 GB disk. Enable SSH, use a dedicated key and a
73
+ passwordless-sudo test user, and make the VM reachable from the control plane.
74
+ Take a VM checkpoint before enrollment. Keep this VM isolated from production
75
+ resources; enrollment changes its packages, services and deployment runtime.
76
+
77
+ ### Ubuntu 22.04 Hyper-V desktop login failure
78
+
79
+ Ubuntu 22.04 LTS can also be used for the disposable test. If Virtual Machine
80
+ Connection shows `login failed for display 0`, the guest is running but its
81
+ enhanced desktop session failed. Try **View → Enhanced Session** (uncheck it)
82
+ and log in through the basic console. This is a
83
+ [documented Ubuntu 22.04 workaround](https://learn.microsoft.com/en-us/answers/questions/1083412/problem-with-ubunti-22-04-on-hyper-v),
84
+ not proof of a networking failure. If basic login works, close any existing
85
+ desktop session before retrying enhanced login and check the guest's xrdp logs
86
+ if it still fails.
87
+
88
+ From the guest console, enable SSH and find the guest address:
89
+
90
+ ```sh
91
+ sudo apt update
92
+ sudo apt install -y openssh-server
93
+ sudo systemctl enable --now ssh
94
+ hostname -I
95
+ ```
96
+
97
+ See [Ubuntu's OpenSSH instructions](https://ubuntu.com/server/docs/how-to/security/openssh-server/).
98
+ If UFW is enabled, allow the OpenSSH profile (`sudo ufw allow OpenSSH`). From
99
+ Windows, check `Test-NetConnection VM_ADDRESS -Port 22`. If it fails, check the
100
+ VM network adapter has a connected virtual switch and the guest has a reachable
101
+ address. Desktop session login and SSH are separate connections.
102
+
103
+ Store the dedicated SSH key and a host alias in local SSH configuration, then
104
+ provide only the alias/configuration path. Verify the host fingerprint against
105
+ the guest console before enrollment. Hyper-V inventory commands may require an
106
+ administrator or Hyper-V Administrators membership; a denied inventory query
107
+ does not establish whether the VM is reachable over SSH.
108
+
109
+ 1. Enroll the VM through the dashboard. Compare its SSH fingerprint against the
110
+ VM console before approving installation.
111
+ 2. Deploy the disposable test project and verify its served content and logs.
112
+ 3. Reboot **the Linux VM**, then verify application content, Docker/Traefik,
113
+ CrowdSec, Alloy, WireGuard, metrics/log arrival and retained operation history.
114
+ 4. Exercise interrupted enrollment and removal on disposable checkpoints. Record
115
+ failures, recovery steps and actual outcomes; do not infer success from a job
116
+ merely being queued.
117
+
118
+ The database and named-volume archive drills require explicit local environment configuration. Store
119
+ paths to keys and known-hosts files in these variables, never key contents in
120
+ chat or the repository:
121
+
122
+ ```sh
123
+ export EPD_DATABASE_E2E_HOST=VM_ADDRESS
124
+ export EPD_DATABASE_E2E_USER=TEST_USER
125
+ export EPD_DATABASE_E2E_KEY=/private/path/test_key
126
+ export EPD_DATABASE_E2E_KNOWN_HOSTS=/private/path/known_hosts
127
+ bun scripts/database-e2e.ts
128
+ bun scripts/archive-e2e.ts
129
+ ```
130
+
131
+ It creates a uniquely named PostgreSQL container/volume, checks archived row
132
+ integrity, rejects a corrupt archive before changing data, checks removal of
133
+ post-snapshot objects and cleans up that fixture. It modifies the specified
134
+ machine and must target a disposable test host. Automatic SQL replacement is
135
+ limited to supported schema-based PostgreSQL databases; complex extensions,
136
+ large objects, replication, event triggers, foreign servers and custom default
137
+ privileges require an operator-managed restore. This is snapshot restore, not
138
+ point-in-time recovery.
139
+
140
+ Project volume archives support declared Docker accessory named volumes. They
141
+ stop the owning accessory while streaming and restore its previous running
142
+ state afterward. Database images require logical backups, and shared running
143
+ writers, bind mounts and process projects are refused. Restore verifies the
144
+ recorded target and checksum, uploads a protection backup and stages replacement.
145
+ Links, special files and unsafe paths are refused before replacing data. If
146
+ rollback cannot complete, recovery files are retained for operator inspection.
147
+ Schedules require explicit administrator policy and `EPD_BACKUP_SCHEDULER=1`.
148
+ Storage bucket/location cannot change under an existing integration; access-key
149
+ rotation is supported. Referenced integrations cannot be deleted while archives
150
+ depend on them.
151
+
152
+ ## Provider and sharing checks
153
+
154
+ - Save R2/Wasabi credentials through Integrations, then explicitly authorize its
155
+ random-object verification job. Only a successful write/read/checksum/delete
156
+ result verifies the target. Enable a database backup policy separately. The
157
+ installation scheduler remains off unless `EPD_BACKUP_SCHEDULER=1`.
158
+ - Restore from the backup page requires administrator access and the exact
159
+ target database name. The job verifies the stored checksum and takes a
160
+ protection backup before mutation. Verify restored data independently.
161
+ - Follow [private repository setup](private-repositories.md) to register the
162
+ GitHub App/GitLab OAuth application. Test both an authorized private clone and
163
+ rejected repositories/organizations. Fixture API tests do not prove provider
164
+ authorization.
165
+ - Billing checkout never activates a subscription by itself. Test signed
166
+ provider webhooks and customer portal behavior with configured Stripe test
167
+ credentials. Existing pricing/business policy still requires owner review.
168
+ - AI guidance is disabled unless `EPD_AI_PROVIDER=openai`, `EPD_AI_MODEL` and
169
+ `OPENAI_API_KEY` are explicitly configured. An organization administrator must
170
+ enable sharing, and each request requires review/confirmation of the redacted
171
+ excerpt. Model output is guidance only and has no execution tools. Requests
172
+ use `store:false`; provider retention policies still apply. No model is
173
+ selected automatically. The adapter follows the
174
+ [official OpenAI text-generation documentation](https://developers.openai.com/api/docs/guides/text).
175
+
176
+ ## Current release gates
177
+
178
+ Record the final check counts, runtime versions, build result and bundle report
179
+ in `log.md`. Record live Linux, reboot, restore and provider checks separately.
180
+ The managed-cloud stack/OpenTofu/domain/PITR work follows the self-hosted release
181
+ gate and the design/business decisions listed in `plans/`.
@@ -8,7 +8,7 @@ Everything you need to prepare your development environment and target servers f
8
8
 
9
9
  `epd` runs on your local development machine or inside a CI runner (such as GitHub Actions).
10
10
 
11
- - **Operating System**: Linux or macOS (or Windows via WSL2).
11
+ - **Operating System**: Linux, macOS, or Windows x64. Windows shell steps require Git Bash from Git for Windows; WSL2 is also an option.
12
12
  - **Standalone Binary**: No local runtimes (Node.js, Bun, Python) are required when using the standalone installer.
13
13
  - **Tools**:
14
14
  - OpenSSH client (`ssh`).
@@ -51,6 +51,17 @@ Installs the pre-compiled, self-contained standalone executable directly for Lin
51
51
  curl -fsSL https://raw.githubusercontent.com/FabioPlunser/epd/main/install.sh | bash
52
52
  ```
53
53
 
54
+ For Windows x64, run in PowerShell (no administrator access needed):
55
+
56
+ ```powershell
57
+ irm https://raw.githubusercontent.com/FabioPlunser/epd/main/install.ps1 | iex
58
+ epd --help
59
+ ```
60
+
61
+ The installer checks the release SHA256 checksum and adds `%LOCALAPPDATA%\epd\bin` to your user PATH. Install Git for Windows and the Windows OpenSSH client. Use Docker Desktop with Linux containers for Docker deployments. Process deployments require `rsync`; use WSL2 if you do not have a Windows-compatible installation. Remote servers and the self-hosted dashboard stack require Linux.
62
+
63
+ To select a version or directory, download `install.ps1` and run `./install.ps1 -Version v0.5.14 -InstallDir C:\Tools\epd`. Pass `-NoPath` to skip PATH changes.
64
+
54
65
  ### Option 2: Bun
55
66
 
56
67
  ```bash
@@ -0,0 +1,44 @@
1
+ # Private repositories in the dashboard
2
+
3
+ Organization administrators can connect a GitHub App installation or a GitLab OAuth account at **Settings → Repository connections**. Create projects using HTTPS clone URLs without passwords, tokens, query strings or `/tree/` browser paths. Public repositories work without a connection. SSH clones use the control plane's SSH configuration.
4
+
5
+ These flows require a registered provider application. EPD cannot create or validate your provider registration without its credentials. Until the variables below are present, settings show the missing configuration and connection attempts fail without saving credentials.
6
+
7
+ ## Shared configuration
8
+
9
+ Set `UI_ENCRYPTION_KEY` to a stable secret kept outside database backups. Set `EPD_PUBLIC_URL` to the dashboard origin, for example `https://epd.example.com`. Callback URLs use this configured origin, never incoming request headers. HTTPS is required outside localhost development. Register callback URLs exactly as shown below and restart the dashboard after changing configuration.
10
+
11
+ OAuth state is encrypted and authenticated in a ten-minute HttpOnly cookie, bound to the provider, organization and signed-in administrator. Both providers use PKCE. Callbacks reject expired, altered or mismatched state. Provider response bodies, tokens and client secrets are never included in error messages.
12
+
13
+ ## GitHub App
14
+
15
+ 1. Register a GitHub App in your account or organization. Grant repository **Contents: Read-only** and the automatically required Metadata permission. Enable user authorization and set the callback URL to `https://epd.example.com/settings/repositories/github/callback`.
16
+ 2. Generate a client secret and App private key. Configure `EPD_GITHUB_CLIENT_ID`, `EPD_GITHUB_CLIENT_SECRET`, `EPD_GITHUB_APP_ID`, `EPD_GITHUB_APP_SLUG` and `EPD_GITHUB_APP_PRIVATE_KEY`. The private key can contain actual newlines or literal `\n` separators. Keep it outside the repository and database.
17
+ 3. Open Repository connections, install the App on selected repositories, then connect GitHub and authorize your account. Choose an installation returned by GitHub for that account. The dashboard independently verifies this selection; an installation ID supplied by a browser never grants access by itself.
18
+ 4. Only repositories visible to the authorizing user at connection time are allowed. Reconnect after adding repositories. Select fewer than 500 repositories in one installation. EPD stores the installation ID and repository allowlist encrypted. The temporary user authorization token is discarded after selection and its pending cookie expires after ten minutes.
19
+
20
+ For each checkout EPD verifies that the requested repository belongs to the saved installation, then requests a short-lived installation token restricted to that repository and read-only Contents permission. Suspended installations and repositories outside the saved allowlist fail before cloning. GitHub Enterprise is not currently supported.
21
+
22
+ If push-triggered deployment is needed, configure the App webhook URL as `https://epd.example.com/api/webhooks/github`, subscribe to Push, and set its secret to `EPD_GITHUB_WEBHOOK_SECRET`. Existing webhook verification rejects missing or incorrect HMAC signatures. OAuth and webhook secrets are separate.
23
+
24
+ See [GitHub user authorization](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app) and [installation tokens](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app).
25
+
26
+ ## GitLab OAuth
27
+
28
+ 1. Register a confidential OAuth application on GitLab with callback URL `https://epd.example.com/settings/repositories/gitlab/callback` and scopes `read_user` and `read_repository`.
29
+ 2. Set `EPD_GITLAB_CLIENT_ID` and `EPD_GITLAB_CLIENT_SECRET`. For a self-managed instance set `EPD_GITLAB_URL` to its HTTPS origin, for example `https://gitlab.example.com`; otherwise GitLab.com is used. Nonstandard HTTPS ports are not supported for clone credential delivery.
30
+ 3. Connect GitLab from Repository connections. EPD exchanges the authorization code with its PKCE verifier, reads the account identity and encrypts its access and refresh tokens. It refreshes expiring tokens during checkout and saves rotated refresh tokens. Refreshes are serialized within the dashboard executor process. Run one dashboard process against the SQLite database.
31
+
32
+ GitLab grants the authorized user's read access to repositories; choose a dedicated account if a narrower sharing boundary is required. Changing the configured GitLab host requires reconnection. For push-triggered deployment configure `https://epd.example.com/api/webhooks/gitlab` and a secret token matching `EPD_GITLAB_WEBHOOK_TOKEN`.
33
+
34
+ See [GitLab OAuth and PKCE documentation](https://docs.gitlab.com/api/oauth2/).
35
+
36
+ ## Credential handling and removal
37
+
38
+ Checkout credentials exist only in the git subprocess environment through an exact repository URL-scoped HTTP Authorization header. HTTP redirects are disabled, inherited git config injection and tracing variables are removed, and credentials are excluded from repository URLs, persistent git configuration and application runtime variables. Git output redacts the token, URL-encoded token and Basic authentication value. A failed checkout removes its verified project workspace; deployment event history stays in the database.
39
+
40
+ Disconnect removes EPD's saved credentials. Also revoke the OAuth authorization or uninstall the App at the provider to remove upstream access. Existing in-progress checkout requests can finish with already-issued short-lived credentials. A disconnected or revoked provider must not be treated as a successful private-repository deployment.
41
+
42
+ ## Verification still required with your accounts
43
+
44
+ Automated tests cover OAuth state/PKCE, organization and role boundaries, installation/repository matching, refresh responses, host restrictions and git credential redaction using mocked provider responses. Complete a real GitHub App and GitLab authorization, private clone and revoked-access failure with your own registered apps before enabling production deployments. No external account registration or live provider authorization is performed by the implementation.
@@ -42,15 +42,38 @@ When you run `epd deploy`:
42
42
  - Your local shell environment (`export DATABASE_URL=...`)
43
43
  - `.env` or `.env.local` in your project root
44
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`.
45
+ 2. `epd` uploads these key-value pairs to the remote server as `0600` files under `/var/lib/epd/apps/<app>/`.
46
46
  3. During startup:
47
- - **Docker Mode**: Mounted securely into containers via `--env-file`.
48
- - **Process Mode**: Loaded into PM2 process environments.
47
+ - **Docker Mode**: Written to a `0600` file and passed to `docker run` via `--env-file`. The file is removed right after the containers start. Docker keeps the values in the container config.
48
+ - **Process Mode**: Written to a `0600` file and handed to PM2 when the processes start. The file is removed right after `pm2 start`. PM2 keeps the environment it was started with, and saves it to its dump.
49
49
 
50
50
  ::: warning Missing Secrets
51
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
52
  :::
53
53
 
54
+ ### Where secrets live on the server
55
+
56
+ epd writes secret values to files under `/var/lib/epd/apps/<app>/`. Every such file is `0600`, and each one is removed as soon as the step that reads it is done, including when that step fails. Nothing is kept for later use:
57
+
58
+ | File (under `/var/lib/epd/apps/<app>/`) | Mode | Written | Removed |
59
+ | --- | --- | --- | --- |
60
+ | `env.<service>` | docker | every service start (deploy, rollback) | right after `docker run`, also when it fails |
61
+ | `env.acc.<name>` | docker, accessories | every accessory start | right after `docker run`, also when it fails |
62
+ | `exec-env.<random>` | docker, process | every `epd exec` (docker: not with `--accessory` or `--reuse`) and `epd shell` in process mode | after the command, also when it fails |
63
+ | `env` | process | every build that has an install or build step | after the build, also when it fails |
64
+ | `pm2.<service>.<slot>.json` | process | every start | right after `pm2 start`, also when it fails |
65
+
66
+ The proxy keeps its DNS-challenge tokens in the same way, under `/var/lib/epd/proxy/`: `env` for docker mode and `pm2.json` for process mode, when `proxy.dns_env` is set. Each one is written right before the proxy starts and removed right after.
67
+
68
+ Older epd versions kept some of these files on the server. The next deploy deletes them: every `env.*` file (service and accessory files) under docker, and `pm2.*.json` and `env` under process mode.
69
+
70
+ After a deploy, two copies of the secret values remain on the server, and both need protecting:
71
+
72
+ - **The container config** (`docker inspect`): anyone who can run `docker inspect` on the server can read the values of every container, including the proxy.
73
+ - **The pm2 dump** (`~/.pm2/dump.pm2` of the SSH user): `pm2 save` records each process's environment there, so the values of every process started by pm2, including the proxy in process mode.
74
+
75
+ Restrict access to the server, not only to the files above.
76
+
54
77
  ---
55
78
 
56
79
  ## 3. Service-Specific Environments
@@ -0,0 +1,104 @@
1
+ # What epd setup installs
2
+
3
+ `epd setup` prepares Docker or the PM2 runtime, starts Traefik, and deploys your
4
+ app. On Debian and Ubuntu servers running systemd, it also configures a secure
5
+ host baseline. Other distributions and containers without systemd emit a warning
6
+ and skip the baseline.
7
+
8
+ To apply it without deploying:
9
+
10
+ ```bash
11
+ epd setup --skip-deploy
12
+ epd doctor
13
+ ```
14
+
15
+ ## Defaults
16
+
17
+ ```yaml
18
+ server:
19
+ auto_updates: true
20
+ firewall: true
21
+ allow: []
22
+ ssh_hardening: true
23
+ log_rotation: true
24
+ reboot_window: "03:00"
25
+ ```
26
+
27
+ All settings describe the host, so use consistent settings across projects that
28
+ share a server. Setting a protection to `false` stops EPD from managing it. It
29
+ does not undo changes from an earlier setup.
30
+
31
+ ## Security updates and time
32
+
33
+ EPD installs unattended-upgrades, enables the daily APT timers, and limits
34
+ unattended upgrades to security origins. Security updates that require a reboot
35
+ can reboot the host at 03:00 in the server's time zone. To require manual reboots,
36
+ set `reboot_window: false`. A single server's reboot interrupts its applications.
37
+
38
+ EPD enables an existing chrony or systemd-timesyncd service, or installs chrony
39
+ if neither is available.
40
+
41
+ ## Firewall and SSH access
42
+
43
+ EPD owns the `inet epd_baseline` nftables table. It never flushes the whole
44
+ ruleset or edits Docker's tables. Host input defaults to drop, with exceptions
45
+ for established traffic, loopback, ICMP including IPv6 discovery, DHCP replies,
46
+ SSH, TCP 80/443, configured Traefik entrypoints, and `server.allow` TCP ports.
47
+
48
+ A separate forwarding chain blocks new connections to other DNAT-published
49
+ ports, including Docker ports that bypass the host input chain. Docker outbound
50
+ traffic keeps its existing forwarding behavior. Cross-host replica ports are
51
+ allowed from the configured proxy peers. For hostname-based cross-host peers,
52
+ set `proxy.private_ips` to their source IP addresses.
53
+
54
+ Add every extra public TCP port needed by applications on the same host to
55
+ `server.allow`. UDP-published services other than DHCP replies are not opened by
56
+ this baseline. Existing firewall rules can still impose additional restrictions.
57
+
58
+ Before changing access, EPD verifies a new SSH connection using public-key
59
+ authentication. It saves the previous EPD firewall table and SSH configuration,
60
+ then arms an independent systemd rollback timer. A second fresh key connection
61
+ must succeed before EPD confirms the change. Failed checks restore the previous
62
+ policy immediately. If the CLI terminates or loses connectivity, the timer
63
+ restores access after 60 seconds. Recovery files are root-only under
64
+ `/var/lib/epd-baseline/epd-baseline-*`.
65
+
66
+ The SSH policy disables password and keyboard-interactive authentication,
67
+ enables public-key authentication, and allows root login only with a key. An
68
+ existing `PermitRootLogin no` remains disabled. EPD
69
+ validates the configuration before reloading SSH. It does not create a
70
+ passwordless sudo rule. Non-root users need existing sudo authorization, an
71
+ interactive sudo password, or `EPD_SUDO_PASSWORD` for unattended runs.
72
+
73
+ The confirmed firewall is loaded on boot by `epd-firewall.service`. Repeated
74
+ setup checks the current rules and avoids reapplying an unchanged policy.
75
+
76
+ ## Docker log limits
77
+
78
+ EPD merges `json-file` logging with `max-size: 10m` and `max-file: 3` into
79
+ `/etc/docker/daemon.json`, preserving unrelated daemon options. It does not
80
+ restart Docker during setup. Restart Docker in a maintenance window, then
81
+ recreate existing containers to apply the limits. Process-mode PM2 logs are not
82
+ managed by this setting.
83
+
84
+ ## Verification
85
+
86
+ `epd doctor` reports missing or changed firewall, SSH, update, and Docker log
87
+ configuration. Docker checks cover configuration on disk, not whether existing
88
+ containers have adopted it.
89
+
90
+ ```bash
91
+ bun run typecheck
92
+ bun test
93
+ bash test/e2e/baseline.sh
94
+ bash test/e2e/run.sh
95
+ ```
96
+
97
+ The baseline test runs a disposable privileged Ubuntu 24.04 systemd container.
98
+ It checks repeat setup, diagnostics, preservation of an unrelated nftables table,
99
+ immediate recovery from an SSH-blocking policy, and timer recovery after CLI
100
+ termination. A real VM remains useful for validating boot ordering and provider
101
+ networking before rolling this out to production servers.
102
+
103
+ The implementation follows [OpenSSH's configuration rules](https://manpages.debian.org/unstable/openssh-server/sshd_config.5.en.html)
104
+ and [Docker's guidance on separate nftables tables and forwarding hooks](https://docs.docker.com/engine/network/firewall-nftables/).
@@ -0,0 +1,40 @@
1
+ # Local S3 wire validation
2
+
3
+ Run the actual dashboard S3 transport against a signature-validating local S3 server:
4
+
5
+ ```sh
6
+ bun scripts/storage-e2e.ts
7
+ ```
8
+
9
+ Docker must provide a Linux engine. The script starts one UUID-named SeaweedFS container, publishes only a random `127.0.0.1` S3 port, and uses temporary credentials generated for that run. Credentials remain in a private temporary JSON configuration, copied into the disposable container with its restrictive file permissions. Using `docker cp` supports a Docker daemon whose filesystem differs from the invoking WSL filesystem. Data uses container tmpfs; no shared Docker volumes or production buckets are involved. The script removes its own container and temporary files in `finally`; it does not prune shared Docker resources. The pulled image remains in the Docker cache.
10
+
11
+ The fixture uses the official `chrislusf/seaweedfs:3.85` release pinned to:
12
+
13
+ ```text
14
+ sha256:49312939c00c01e5ee6afbd7d728b18027821d3764c35a797a72acd4fdf3296a
15
+ ```
16
+
17
+ Primary references are the [SeaweedFS 3.85 release](https://github.com/seaweedfs/seaweedfs/releases/tag/3.85), its [Docker instructions](https://github.com/seaweedfs/seaweedfs/blob/3.85/docker/README.md), and the project's [S3 credential configuration](https://github.com/seaweedfs/seaweedfs/blob/master/docker/compose/s3.json). The fixture config enables credential-based access and contains no anonymous identity. It verifies rejection by the running server rather than assuming that authentication is enabled.
18
+
19
+ The assertions use `database-storage.ts` directly:
20
+
21
+ - Signed streaming PUT and GET preserve 2,097,169 random bytes and their SHA256 checksum.
22
+ - A request signed with the wrong secret returns HTTP 403 `SignatureDoesNotMatch`.
23
+ - A mismatched expected checksum is rejected before a caller can restore the downloaded file.
24
+ - Signed DELETE removes the object; a subsequent signed GET returns HTTP 404.
25
+
26
+ The local HTTP exemption is enabled only for the fixture process and restored afterward. Deployed storage integrations require HTTPS.
27
+
28
+ ## PostgreSQL through stored objects
29
+
30
+ The disposable Docker dashboard harness includes the storage fixture:
31
+
32
+ ```sh
33
+ bun test/web-e2e/run.ts --storage-only
34
+ ```
35
+
36
+ It supplies its temporary pinned SSH transport to `storage-e2e.ts` with `EPD_STORAGE_E2E_PG=1`. The fixture then calls the PostgreSQL drill with a temporary `EPD_STORAGE_FIXTURE_CONFIG` file. The drill provisions PostgreSQL on the disposable host, writes known rows, creates a CLI archive, uploads it through the actual S3 adapter, and downloads and checks the stored archive. It corrupts a separate archive to verify rejection before mutation, then restores from the downloaded S3 object. Restored row count, row checksum and removal of post-snapshot objects must all pass. The harness also runs the named-volume archive restoration drill.
37
+
38
+ Artifacts include `database-storage-restore-drill.log`, `volume-archive-drill.log` and the harness scenario log in its reported temporary artifact directory.
39
+
40
+ This validates the local SigV4 wire format and stored-object restore path. It does not verify a real R2 or Wasabi account, provider-specific permissions, lifecycle policies or regional behavior. Run the integration's explicit storage verification job with an authorized test bucket before claiming that provider account works.
@@ -41,17 +41,21 @@ The new version was booted in the idle slot, but requests to `healthcheck.path`
41
41
  ```
42
42
 
43
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.
44
+ `epd` takes a lock on every server before deploying: a directory at `<remote_root>/apps/<app>/lock` (`/var/lib/epd/apps/<app>/lock` by default), created with `mkdir`, which is atomic. It holds who took it, the machine and process ID, the time, and what the deploy was doing. On Ctrl-C or SIGTERM, `epd` releases the locks it holds, including one it was in the middle of taking, but only where the lock still records this deploy as its holder. That release waits up to about 25 seconds for slow servers. A second Ctrl-C exits at once, which can leave the lock; `epd lock release` clears it. If your computer lost its connection, or the deploy was killed with `kill -9` mid-deployment, the lock stays until someone releases it.
45
+
46
+ `epd lock status` flags a lock as probably stale when its process is no longer running on the same machine, or when it has been held for more than 6 hours.
45
47
 
46
48
  ### Solution:
47
49
  ```bash
48
- # Check lock details:
50
+ # Check lock details and whether it looks stale:
49
51
  epd lock status
50
52
 
51
- # Forcefully clear the lock:
53
+ # Clear the lock once you have confirmed no deploy is running:
52
54
  epd lock release
53
55
  ```
54
56
 
57
+ Only release a lock you are sure is stale. Releasing a live deploy's lock lets a second deploy run at the same time.
58
+
55
59
  ---
56
60
 
57
61
  ## 3. Investigating the Shared Traefik Proxy
@@ -58,6 +58,58 @@ The `epd` command line is organized into five functional categories:
58
58
 
59
59
  ---
60
60
 
61
+ ## Global options
62
+
63
+ | Option | Description |
64
+ | --- | --- |
65
+ | `-c, --config <file>` | Path to `epd.yml` |
66
+ | `-d, --destination <d>` | Overlay `epd.<d>.yml` (staging, production, …) |
67
+ | `-v, --verbose` | Print every command epd runs |
68
+ | `--log-format <pretty\|json>` | Output format (also `EPD_LOG_FORMAT`). See below. |
69
+
70
+ ### Run logs
71
+
72
+ Every command writes a complete, timestamped log on the machine running epd,
73
+ including the output of every build and remote command and the debug detail
74
+ that `--verbose` would show. When a command fails, epd prints the path:
75
+
76
+ ```
77
+ Full log: ~/.local/state/epd/logs/2026-10-07_15-29-06-deploy-18749.log
78
+ ```
79
+
80
+ Logs live in `$XDG_STATE_HOME/epd/logs` (default `~/.local/state/epd/logs`), the
81
+ newest 200 are kept. Set `EPD_LOG_DIR` to move them, or `EPD_LOG_DIR=off` to
82
+ disable them.
83
+
84
+ A command that produces no output for 20 seconds reports that it is still
85
+ running (`… still running: docker buildx build (40s)`), so a slow step is never
86
+ mistaken for a hung one. When a deploy fails on a host, epd prints the state,
87
+ exit code and last log lines of the containers it started before rolling back.
88
+
89
+ ### Machine-readable output
90
+
91
+ With `--log-format json` every line on stdout is one JSON event, and the last
92
+ line is always a `result` event, even for argument errors and interrupts:
93
+
94
+ ```json
95
+ {"ts":"…","t":12,"level":"step","msg":"Preparing servers","phase":"prepare"}
96
+ {"ts":"…","t":840,"level":"output","msg":"#5 DONE 0.4s","stream":"stderr","label":"docker buildx build"}
97
+ {"ts":"…","t":9120,"level":"host","host":"10.0.0.5","msg":"web: healthy","phase":"health"}
98
+ {"ts":"…","t":9900,"level":"result","ok":true,"code":0,"msg":"ok","logFile":"/…/deploy.log"}
99
+ ```
100
+
101
+ | Field | Meaning |
102
+ | --- | --- |
103
+ | `level` | `step`, `info`, `ok`, `warn`, `error`, `debug`, `host`, `output`, `plain`, `result` |
104
+ | `phase` | On `step`/`host` events: `plan`, `connect`, `build`, `push`, `hooks`, `prepare`, `accessories`, `proxy`, `deploy`, `health`, `routes`, `diagnose` |
105
+ | `host` | The server the line concerns |
106
+ | `stream`, `label` | For `output`: child stream and the command that produced it |
107
+ | `ok`, `code`, `hint`, `logFile` | On the final `result` event |
108
+
109
+ json mode never prompts. On SIGINT/SIGTERM epd releases the deploy lock, emits
110
+ a `result` with code 130/143 and exits, so CI runners and the web control plane
111
+ can cancel a deploy safely.
112
+
61
113
  ## `epd init`
62
114
 
63
115
  Interactively initializes `epd.yml` for the current project.
@@ -296,6 +348,49 @@ epd maintenance off # Disable maintenance mode and restore traff
296
348
 
297
349
  ---
298
350
 
351
+ ## `epd database`
352
+
353
+ Provision and verify a self-hosted PostgreSQL accessory, or stream a logical database backup and restore. Docker must already be installed on the target. Provisioning publishes PostgreSQL to host loopback, retains a persistent Docker volume, refuses existing containers or volumes, and succeeds only after `SELECT 1` works.
354
+
355
+ ```bash
356
+ epd database provision --accessory database --port 5432 --memory 1024
357
+ epd database check --accessory database
358
+ epd database backup --accessory database --file ./database.sql.gz
359
+ epd database restore --accessory database --file ./database.sql.gz --yes
360
+ ```
361
+
362
+ The accessory must use a supported PostgreSQL Alpine image and define `POSTGRES_DB`, `POSTGRES_USER`, and a password of at least 20 characters. Backups use `pg_dump --clean --if-exists`; restore runs SQL in a single transaction with `ON_ERROR_STOP`, then verifies a query. Restore replaces database objects, so create a protection backup first. External clients must forward the host loopback port through SSH.
363
+
364
+ ---
365
+
366
+ ## `epd archive`
367
+
368
+ Archive a non-database Docker accessory's declared named volume. This is the supported project volume archive path used by the dashboard. Select a volume by its zero-based position in the accessory's `volumes` list.
369
+
370
+ ```yaml
371
+ accessories:
372
+ uploads:
373
+ image: alpine:3.22
374
+ host: 203.0.113.10
375
+ command: sleep 86400
376
+ volumes:
377
+ - uploads_data:/data
378
+ ```
379
+
380
+ ```bash
381
+ epd archive backup --accessory uploads --volume-index 0 --file ./uploads.tar.gz --log-format json
382
+ # Record the SHA256 target fingerprint in the ARCHIVE_TARGET log message.
383
+ epd archive restore --accessory uploads --volume-index 0 --file ./uploads.tar.gz --expected-target <recorded-fingerprint> --yes
384
+ ```
385
+
386
+ Backup and restore stop the owning accessory while streaming and restore its original running state afterward. The configured named volume must be mounted by that accessory; another running container using it prevents the operation. Bind mounts, process-mode projects and database images are unsupported here. Use logical database backups for databases.
387
+
388
+ Restore verifies that the host, accessory container, named volume and destination match the recorded target. It rejects traversal paths, links and special files, extracts into staging, and copies current contents before replacement. If rollback itself fails, `.epd-archive-old` retains recovery data. Existing `.epd-archive-*` entries block another operation until an operator inspects them. Leave enough free volume space for the archive, staged extraction and protection copy.
389
+
390
+ The dashboard adds organization and role checks, pinned SSH credentials, uploaded archive SHA256 read-back verification, a verified protection backup before restore, explicit storage-object deletion and opt-in scheduled retention. Its restore form requires the exact project name. Direct CLI archives remain local files; keep and verify a separate protection backup before confirming replacement.
391
+
392
+ ---
393
+
299
394
  ## `epd backup`
300
395
 
301
396
  Create compressed database and volume backups from running accessories (PostgreSQL, MySQL, MariaDB, MongoDB, or generic persistent volumes).
@@ -386,10 +481,12 @@ epd sevalla deploy <id> # Trigger deployment of a Sevalla application
386
481
  Manage atomic deployment locks.
387
482
 
388
483
  ```bash
389
- epd lock status # Check who currently holds the deploy lock
390
- epd lock release # Forcefully release the deploy lock
484
+ epd lock status # Who holds the deploy lock on each server; flags locks that look stale
485
+ epd lock release # Release the deploy lock on every server (use when no deploy is running)
391
486
  ```
392
487
 
488
+ A lock looks stale when the process that took it is gone (same machine) or it has been held for more than 6 hours. `epd lock release` is the override. `epd deploy --skip-lock` ignores the lock for a single deploy, and should be used only with the same care.
489
+
393
490
  ---
394
491
 
395
492
  ## `epd remove`