@fabioplunser/epd 0.5.0 → 0.5.1

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 CHANGED
@@ -139,14 +139,15 @@ build:
139
139
  npm_token: NPM_TOKEN
140
140
 
141
141
  ssh:
142
- user: root
142
+ user: root # default login; a non-root user needs passwordless sudo
143
143
  port: 22
144
144
  key: ~/.ssh/id_ed25519
145
145
  proxy_jump: bastion.example.com
146
146
 
147
147
  servers:
148
148
  web:
149
- hosts: [203.0.113.10, 203.0.113.11]
149
+ # "user@host" overrides ssh.user for that one server.
150
+ hosts: [203.0.113.10, deploy@203.0.113.11]
150
151
  replicas: 2 # per host, load balanced by the proxy
151
152
  port: 3000 # the port your app listens on
152
153
  domains: [example.com, www.example.com]
package/dist/cli.js CHANGED
@@ -205,6 +205,22 @@ function deepMerge(base, overlay) {
205
205
  function fail(path, msg, hint) {
206
206
  throw new EpdError(`${path}: ${msg}`, hint);
207
207
  }
208
+ function takeHostUser(entry, path, users) {
209
+ const at = entry.lastIndexOf("@");
210
+ if (at < 0)
211
+ return entry;
212
+ const user = entry.slice(0, at);
213
+ const host = entry.slice(at + 1);
214
+ if (!user || !host) {
215
+ fail(path, `"${entry}" is not a valid host`, 'Write it as "user@host", e.g. "deploy@10.0.0.1".');
216
+ }
217
+ const seen = users[host];
218
+ if (seen && seen !== user) {
219
+ fail(path, `host ${host} is listed as both ${seen}@${host} and ${user}@${host}`, "Use one ssh user per host.");
220
+ }
221
+ users[host] = user;
222
+ return host;
223
+ }
208
224
  function asString(v, path, dflt) {
209
225
  if (v === undefined || v === null) {
210
226
  if (dflt !== undefined)
@@ -523,6 +539,7 @@ function normalize(raw, configPath, root, destination) {
523
539
  delay: 1
524
540
  };
525
541
  const rootHealth = parseHealth(raw.healthcheck ?? raw.health, "epd.yml.healthcheck", defaultHealth);
542
+ const hostUsers = {};
526
543
  let servicesRaw = raw.services ?? raw.servers;
527
544
  const inlineKeys = ["hosts", "host", "replicas", "port", "domain", "domains", "routes", "command", "labels", "volumes", "drain", "stop_timeout", "docker_options"];
528
545
  const hasInline = inlineKeys.some((k) => raw[k] !== undefined);
@@ -590,7 +607,10 @@ function normalize(raw, configPath, root, destination) {
590
607
  fail(`${p}.hetzner`, "expected a server name string or a mapping");
591
608
  }
592
609
  }
593
- const hosts = [...asList(o.host, `${p}.host`), ...asList(o.hosts, `${p}.hosts`)];
610
+ const hosts = [
611
+ ...asList(o.host, `${p}.host`).map((h) => takeHostUser(h, `${p}.host`, hostUsers)),
612
+ ...asList(o.hosts, `${p}.hosts`).map((h) => takeHostUser(h, `${p}.hosts`, hostUsers))
613
+ ];
594
614
  if (!hosts.length && !svcHetzner)
595
615
  fail(`${p}.hosts`, "at least one host is required");
596
616
  const port = asNumber(o.port, `${p}.port`, asNumber(raw.port, "epd.yml.port", 3000));
@@ -638,7 +658,7 @@ function normalize(raw, configPath, root, destination) {
638
658
  return {
639
659
  name: accName,
640
660
  image: asString(o.image, `${p}.image`),
641
- host: asString(o.host, `${p}.host`),
661
+ host: takeHostUser(asString(o.host, `${p}.host`), `${p}.host`, hostUsers),
642
662
  env: asDict(accEnvRaw?.clear ?? (accEnvRaw && !("clear" in accEnvRaw) && !("secret" in accEnvRaw) ? accEnvRaw : {}), `${p}.env`),
643
663
  secrets: asList(accEnvRaw?.secret, `${p}.env.secret`),
644
664
  volumes: asList(o.volumes, `${p}.volumes`),
@@ -777,6 +797,7 @@ function normalize(raw, configPath, root, destination) {
777
797
  },
778
798
  ssh: {
779
799
  user: asString(sshRaw.user, "epd.yml.ssh.user", "root"),
800
+ hostUsers,
780
801
  port: asNumber(sshRaw.port, "epd.yml.ssh.port", 22),
781
802
  key: sshRaw.key ? expandHome(asString(sshRaw.key, "epd.yml.ssh.key")) : undefined,
782
803
  options: asList(sshRaw.options, "epd.yml.ssh.options"),
@@ -1568,6 +1589,15 @@ dns:
1568
1589
  proxied: true
1569
1590
  auto_sync: true
1570
1591
  ` : "";
1592
+ const sshBlock = `
1593
+ # How epd reaches your servers: plain ssh with your own key, no agent installed.
1594
+ # A non-root user needs passwordless sudo (epd escalates with "sudo -n").
1595
+ ssh:
1596
+ user: ${o.sshUser}
1597
+ # port: 22
1598
+ # key: ~/.ssh/id_ed25519
1599
+ # proxy_jump: bastion.example.com
1600
+ `;
1571
1601
  const hetznerBlock = o.useHetzner ? `
1572
1602
  # Hetzner Cloud integration (api_token resolved from ~/.config/epd/auth.json or HETZNER_API_TOKEN)
1573
1603
  hetzner:
@@ -1588,8 +1618,9 @@ mode: ${o.mode}
1588
1618
  ${o.mode === "docker" ? `
1589
1619
  # Image name. Tagged with the git sha of every deploy.
1590
1620
  image: ${o.image ?? o.name}
1591
- ${registry}` : ""}${processBlock}${dnsBlock}${hetznerBlock}
1621
+ ${registry}` : ""}${processBlock}${sshBlock}${dnsBlock}${hetznerBlock}
1592
1622
  # One entry per group of processes. Add more (worker, cron, \u2026) as you need them.
1623
+ # A host may carry its own login \u2014 "deploy@203.0.113.10" overrides ssh.user.
1593
1624
  servers:
1594
1625
  web:
1595
1626
  hosts: ${list(o.hosts)}
@@ -1709,6 +1740,7 @@ var init = {
1709
1740
  domain: { type: "string", multiple: true },
1710
1741
  port: { type: "string" },
1711
1742
  email: { type: "string" },
1743
+ "ssh-user": { type: "string" },
1712
1744
  replicas: { type: "string" },
1713
1745
  force: { type: "boolean" },
1714
1746
  dockerfile: { type: "boolean" },
@@ -1727,6 +1759,7 @@ Options
1727
1759
  --domain <domain> Domain to serve (repeatable)
1728
1760
  --port <port> Port your app listens on
1729
1761
  --email <email> Contact address for Let's Encrypt
1762
+ --ssh-user <user> SSH login for the servers (default root)
1730
1763
  --replicas <n> Replicas per host (default 1)
1731
1764
  --dockerfile Also write a starter Dockerfile
1732
1765
  --ci Also generate a GitHub Actions deploy workflow (.github/workflows/deploy.yml)
@@ -1835,6 +1868,7 @@ Options
1835
1868
  const domains = (ctx.values.domain ?? []).length ? ctx.values.domain : (await ask("Domains to serve (comma separated)", defaultDomain)).split(",").map((s) => s.trim()).filter(Boolean);
1836
1869
  const port = Number(ctx.values.port ?? await ask("Port your app listens on", String(detected.port)));
1837
1870
  const email = ctx.values.email ?? await ask("Email for Let's Encrypt", "");
1871
+ const sshUser = ctx.values["ssh-user"] ?? await ask("SSH user for the server(s)", "root");
1838
1872
  const replicas = Number(ctx.values.replicas ?? 1);
1839
1873
  let registryUser;
1840
1874
  let registryServer;
@@ -1847,6 +1881,7 @@ Options
1847
1881
  writeFileSync2(target, template({
1848
1882
  name,
1849
1883
  mode,
1884
+ sshUser: sshUser || "root",
1850
1885
  hosts,
1851
1886
  domains,
1852
1887
  port,
@@ -2193,15 +2228,20 @@ import { tmpdir } from "os";
2193
2228
  import { join as join4 } from "path";
2194
2229
  var controlDir = join4(tmpdir(), `epd-${process.getuid?.() ?? 0}`);
2195
2230
  mkdirSync3(controlDir, { recursive: true, mode: 448 });
2231
+ function sshUserFor(name, cfg) {
2232
+ return cfg.hostUsers?.[name] ?? cfg.user;
2233
+ }
2196
2234
 
2197
2235
  class Host {
2198
2236
  name;
2237
+ user;
2199
2238
  cfg;
2200
2239
  sudo;
2201
2240
  constructor(name, cfg) {
2202
2241
  this.name = name;
2203
- this.cfg = cfg;
2204
- this.sudo = cfg.user !== "root";
2242
+ this.user = sshUserFor(name, cfg);
2243
+ this.cfg = this.user === cfg.user ? cfg : { ...cfg, user: this.user };
2244
+ this.sudo = this.user !== "root";
2205
2245
  }
2206
2246
  sshOptions() {
2207
2247
  const socket = join4(controlDir, `${hash32(`${this.cfg.user}@${this.name}:${this.cfg.port}`).toString(36)}.sock`);
@@ -2311,7 +2351,7 @@ function dirnameOf(p) {
2311
2351
  }
2312
2352
  var cache = new Map;
2313
2353
  function host(name, cfg) {
2314
- const key = `${cfg.user}@${name}:${cfg.port}`;
2354
+ const key = `${sshUserFor(name, cfg)}@${name}:${cfg.port}`;
2315
2355
  let h = cache.get(key);
2316
2356
  if (!h) {
2317
2357
  h = new Host(name, cfg);
@@ -4863,7 +4903,8 @@ Options
4863
4903
  else
4864
4904
  log.plain(` start ${cfg.process.start}`);
4865
4905
  log.plain(` hosts ${allHosts(cfg).join(", ")}`);
4866
- log.plain(` ssh ${cfg.ssh.user}@\u2026:${cfg.ssh.port}`);
4906
+ const sshOverrides = Object.entries(cfg.ssh.hostUsers).filter(([, u]) => u !== cfg.ssh.user).map(([h, u]) => `${u}@${h}`);
4907
+ log.plain(` ssh ${cfg.ssh.user}@\u2026:${cfg.ssh.port}${sshOverrides.length ? c.gray(` (${sshOverrides.join(", ")})`) : ""}`);
4867
4908
  log.plain(` strategy ${cfg.strategy}`);
4868
4909
  if (usesHostPorts(cfg)) {
4869
4910
  const b = portBlock(cfg);
@@ -5766,7 +5807,7 @@ async function promptAutoUpdate(currentVersion) {
5766
5807
  }
5767
5808
 
5768
5809
  // src/version.ts
5769
- var VERSION = "0.5.0";
5810
+ var VERSION = "0.5.1";
5770
5811
 
5771
5812
  // src/commands/update.ts
5772
5813
  var update = {
@@ -120,6 +120,23 @@ ssh:
120
120
  proxy_jump: bastion.example.com
121
121
  ```
122
122
 
123
+ `ssh.user` is the login for every server. A non-root user must be able to run
124
+ `sudo -n` without a password — epd escalates for docker, systemd and the files
125
+ under `/var/lib/epd`:
126
+
127
+ ```
128
+ deploy ALL=(ALL) NOPASSWD:ALL
129
+ ```
130
+
131
+ To use a different login on a single server, write it into the host entry —
132
+ that wins over `ssh.user`:
133
+
134
+ ```yaml
135
+ servers:
136
+ web:
137
+ hosts: ["deploy@203.0.113.10", "ubuntu@203.0.113.11"]
138
+ ```
139
+
123
140
  ---
124
141
 
125
142
  ## Next Step
@@ -50,6 +50,9 @@ process:
50
50
  # ==============================================================================
51
51
  ssh:
52
52
  user: root # SSH username (default: root)
53
+ # Any non-root user needs passwordless sudo.
54
+ # Override it per server by writing the login
55
+ # into the host entry: "deploy@203.0.113.10".
53
56
  port: 22 # SSH port (default: 22)
54
57
  key: ~/.ssh/id_ed25519 # Path to explicit private key
55
58
  proxy_jump: bastion.net # Optional jump host / bastion
@@ -63,6 +66,7 @@ servers:
63
66
  web:
64
67
  hosts: # Target servers (IPs or Hetzner selectors)
65
68
  - 203.0.113.10
69
+ - deploy@203.0.113.11 # Per-host ssh login, overrides ssh.user
66
70
  - hetzner:prod-web-1 # Dynamic Hetzner query by server name
67
71
  - hetzner:label:app=web # Dynamic Hetzner query by label selector
68
72
  replicas: 2 # Number of container replicas per host
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@fabioplunser/epd",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Easy Project Deployer — deploy any project to one or many servers with Docker or PM2, fronted by Traefik.",
5
5
  "type": "module",
6
6
  "author": "Fabio Plünser",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/FabioPlunser/epd#readme",
8
+ "homepage": "https://epd.peppi.dev",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/FabioPlunser/epd"
@@ -33,6 +33,9 @@
33
33
  "LICENSE",
34
34
  "docs"
35
35
  ],
36
+ "workspaces": [
37
+ "apps/*"
38
+ ],
36
39
  "publishConfig": {
37
40
  "access": "public"
38
41
  },
@@ -44,6 +47,8 @@
44
47
  "build:binaries": "bun run scripts/build-all.ts",
45
48
  "typecheck": "tsc --noEmit",
46
49
  "test": "bun test",
50
+ "web:dev": "cd apps/web && bun run dev",
51
+ "web:build": "cd apps/web && bun run build",
47
52
  "docs:dev": "vitepress dev docs",
48
53
  "docs:build": "vitepress build docs",
49
54
  "docs:preview": "vitepress preview docs",
@@ -53,7 +58,7 @@
53
58
  "bun": ">=1.1.0"
54
59
  },
55
60
  "devDependencies": {
56
- "@types/bun": "latest",
61
+ "@types/bun": "^1.4.1",
57
62
  "typescript": "^5.6.0",
58
63
  "vitepress": "^1.6.4"
59
64
  }