vercel-vm-factory 0.7.8 → 0.8.8

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
@@ -63,6 +63,8 @@ Shell options:
63
63
  - `/bin/zsh`
64
64
  - `/bin/sh`
65
65
 
66
+ Choosing bash or zsh adds the matching package to the generated Dockerfile when the VM image does not already include it.
67
+
66
68
  Custom VM image:
67
69
 
68
70
  ```bash
package/deploy-vm.mjs CHANGED
@@ -113,7 +113,12 @@ async function main() {
113
113
  ".generated",
114
114
  project,
115
115
  );
116
- const dockerfile = makeDockerfile({ shell, vmImage, wsShellImage });
116
+ const dockerfile = makeDockerfile({
117
+ shell,
118
+ vmImage,
119
+ vmImageName,
120
+ wsShellImage,
121
+ });
117
122
 
118
123
  await rm(appDir, { recursive: true, force: true });
119
124
  await mkdir(appDir, { recursive: true });
@@ -348,13 +353,14 @@ async function doctor() {
348
353
  );
349
354
  }
350
355
 
351
- function makeDockerfile({ shell, vmImage, wsShellImage }) {
356
+ function makeDockerfile({ shell, vmImage, vmImageName, wsShellImage }) {
357
+ const shellInstall = makeShellInstall({ shell, vmImageName });
352
358
  return `ARG WS_SHELL_IMAGE=${wsShellImage}
353
359
  ARG VM_IMAGE=${vmImage}
354
360
 
355
361
  FROM \${WS_SHELL_IMAGE} AS ws-shell
356
362
  FROM \${VM_IMAGE} AS vm
357
-
363
+ ${shellInstall ? `\n${shellInstall}\n` : ""}
358
364
  # wsterm already embeds the web UI; runtime config comes from environment variables.
359
365
  COPY --from=ws-shell /app/bin/wsterm /app/bin/wsterm
360
366
 
@@ -365,6 +371,32 @@ CMD ["/app/bin/wsterm","-bind",":80","-fork","${shell}"]
365
371
  `;
366
372
  }
367
373
 
374
+ function makeShellInstall({ shell, vmImageName }) {
375
+ const packageName = path.basename(shell);
376
+ if (packageName === "sh") return "";
377
+
378
+ if (vmImageName === "alpine")
379
+ return `RUN apk add --no-cache ${packageName}`;
380
+
381
+ if (vmImageName === "ubuntu" || vmImageName === "debian")
382
+ return `RUN apt-get update \\
383
+ && apt-get install -y --no-install-recommends ${packageName} \\
384
+ && rm -rf /var/lib/apt/lists/*`;
385
+
386
+ return `RUN if command -v ${shell} >/dev/null 2>&1; then \\
387
+ true; \\
388
+ elif command -v apk >/dev/null 2>&1; then \\
389
+ apk add --no-cache ${packageName}; \\
390
+ elif command -v apt-get >/dev/null 2>&1; then \\
391
+ apt-get update \\
392
+ && apt-get install -y --no-install-recommends ${packageName} \\
393
+ && rm -rf /var/lib/apt/lists/*; \\
394
+ else \\
395
+ echo "Cannot install ${packageName}: unsupported VM image package manager" >&2; \\
396
+ exit 1; \\
397
+ fi`;
398
+ }
399
+
368
400
  async function value(name, question, fallback) {
369
401
  const current = args[name] ?? fallback;
370
402
  if (args[name]) return args[name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vercel-vm-factory",
3
- "version": "0.7.8",
3
+ "version": "0.8.8",
4
4
  "description": "Create Vercel Container deployments for ws-shell from selectable VM images.",
5
5
  "license": "MIT",
6
6
  "type": "module",