ezhst 1.3.1 → 1.3.2
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/dist/commands/build.js +97 -36
- package/dist/commands/deploy.js +20 -14
- package/dist/index.js +14 -13
- package/package.json +1 -1
- package/skill/SKILL.md +15 -6
package/dist/commands/build.js
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { select } from "@inquirer/prompts";
|
|
1
3
|
import { json, request } from "../lib/api.js";
|
|
2
4
|
import { resolveApp } from "../lib/project.js";
|
|
3
|
-
import { log, output } from "../lib/ui.js";
|
|
5
|
+
import { fail, isInteractive, log, output } from "../lib/ui.js";
|
|
4
6
|
const settingsOf = (project) => ({
|
|
5
|
-
nodeVersion: project.nodeVersion,
|
|
6
7
|
rootDir: project.rootDir,
|
|
7
|
-
|
|
8
|
-
buildCommand: project.buildCommand,
|
|
9
|
-
startCommand: project.startCommand,
|
|
8
|
+
dockerfile: project.dockerfile,
|
|
10
9
|
});
|
|
11
10
|
const printSettings = (project) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
["Build command", project.buildCommand],
|
|
17
|
-
["Start command", project.startCommand],
|
|
18
|
-
];
|
|
19
|
-
for (const [label, value] of rows) {
|
|
20
|
-
log.info(`${label.padEnd(17)} ${value ?? "auto"}`);
|
|
11
|
+
log.info(`Root directory ${project.rootDir ?? "project root"}`);
|
|
12
|
+
if (!project.dockerfile) {
|
|
13
|
+
log.info("Dockerfile not set");
|
|
14
|
+
return;
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (value === undefined) {
|
|
25
|
-
return current ?? "";
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
16
|
+
log.info("Dockerfile:\n");
|
|
17
|
+
process.stdout.write(`${project.dockerfile}\n`);
|
|
28
18
|
};
|
|
29
19
|
const saveSettings = async (project, settings) => {
|
|
30
20
|
const { app } = await request(`/apps/${project.id}/build`, json("PUT", settings));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
return app;
|
|
22
|
+
};
|
|
23
|
+
const readStdin = async () => {
|
|
24
|
+
const chunks = [];
|
|
25
|
+
for await (const chunk of process.stdin) {
|
|
26
|
+
chunks.push(chunk);
|
|
27
|
+
}
|
|
28
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
29
|
+
};
|
|
30
|
+
const readDockerfile = async (file) => {
|
|
31
|
+
if (file === "-") {
|
|
32
|
+
return readStdin();
|
|
33
|
+
}
|
|
34
|
+
if (!existsSync(file)) {
|
|
35
|
+
return fail(`${file} not found.`);
|
|
36
|
+
}
|
|
37
|
+
return readFileSync(file, "utf8");
|
|
38
|
+
};
|
|
39
|
+
const listTemplates = async () => {
|
|
40
|
+
const { templates } = await request("/apps/dockerfile-templates");
|
|
41
|
+
return templates;
|
|
35
42
|
};
|
|
36
43
|
export const showBuild = async (options) => {
|
|
37
44
|
const project = await resolveApp(options);
|
|
@@ -39,19 +46,73 @@ export const showBuild = async (options) => {
|
|
|
39
46
|
};
|
|
40
47
|
export const setBuild = async (options) => {
|
|
41
48
|
const project = await resolveApp(options);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
nodeVersion,
|
|
48
|
-
rootDir: pick(options.rootDir, project.rootDir),
|
|
49
|
-
installCommand: pick(options.install, project.installCommand),
|
|
50
|
-
buildCommand: pick(options.build, project.buildCommand),
|
|
51
|
-
startCommand: pick(options.start, project.startCommand),
|
|
52
|
-
});
|
|
49
|
+
if (options.rootDir === undefined) {
|
|
50
|
+
fail("Nothing to change. Pass --root-dir <dir>.");
|
|
51
|
+
}
|
|
52
|
+
const app = await saveSettings(project, { rootDir: options.rootDir });
|
|
53
|
+
output({ build: settingsOf(app) }, () => log.success(`Root directory set to ${app.rootDir ?? "project root"}. Run \`ezhst redeploy\` to apply it.`));
|
|
53
54
|
};
|
|
54
55
|
export const resetBuild = async (options) => {
|
|
55
56
|
const project = await resolveApp(options);
|
|
56
|
-
await saveSettings(project, {
|
|
57
|
+
const app = await saveSettings(project, { rootDir: "", dockerfile: "" });
|
|
58
|
+
output({ build: settingsOf(app) }, () => log.success("Build settings cleared. Set a Dockerfile before the next deploy."));
|
|
59
|
+
};
|
|
60
|
+
export const showDockerfile = async (options) => {
|
|
61
|
+
const project = await resolveApp(options);
|
|
62
|
+
output({ dockerfile: project.dockerfile }, () => {
|
|
63
|
+
if (!project.dockerfile) {
|
|
64
|
+
log.info("No Dockerfile set. Run `ezhst build dockerfile template` to list templates.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
process.stdout.write(`${project.dockerfile}\n`);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
export const setDockerfile = async (options) => {
|
|
71
|
+
const project = await resolveApp(options);
|
|
72
|
+
const content = await readDockerfile(options.file);
|
|
73
|
+
const app = await saveSettings(project, { dockerfile: content });
|
|
74
|
+
output({ build: settingsOf(app) }, () => log.success("Dockerfile saved. Run `ezhst deploy` or `ezhst redeploy` to build with it."));
|
|
75
|
+
};
|
|
76
|
+
export const dockerfileTemplate = async (id, options) => {
|
|
77
|
+
const templates = await listTemplates();
|
|
78
|
+
if (!id) {
|
|
79
|
+
output({ templates: templates.map((template) => ({ id: template.id, label: template.label })) }, () => {
|
|
80
|
+
for (const template of templates) {
|
|
81
|
+
log.info(`${template.id.padEnd(8)} ${template.label}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const template = templates.find((item) => item.id === id);
|
|
87
|
+
if (!template) {
|
|
88
|
+
return fail(`Unknown template ${id}. Available: ${templates.map((item) => item.id).join(", ")}`);
|
|
89
|
+
}
|
|
90
|
+
if (!options.apply) {
|
|
91
|
+
output({ template }, () => process.stdout.write(template.content));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const project = await resolveApp(options);
|
|
95
|
+
const app = await saveSettings(project, { dockerfile: template.content });
|
|
96
|
+
output({ build: settingsOf(app) }, () => log.success(`${template.label} Dockerfile saved. Review it with \`ezhst build dockerfile show\`.`));
|
|
97
|
+
};
|
|
98
|
+
export const ensureDockerfile = async (project) => {
|
|
99
|
+
if (project.dockerfile) {
|
|
100
|
+
return project;
|
|
101
|
+
}
|
|
102
|
+
const hint = "This app has no Dockerfile. Write one and run `ezhst build dockerfile set -f Dockerfile`, or start from a template with `ezhst build dockerfile template <id> --apply`.";
|
|
103
|
+
if (!isInteractive()) {
|
|
104
|
+
fail(hint);
|
|
105
|
+
}
|
|
106
|
+
const templates = await listTemplates();
|
|
107
|
+
const choice = await select({
|
|
108
|
+
message: "This app has no Dockerfile. Start from a template?",
|
|
109
|
+
choices: [...templates.map((template) => ({ name: template.label, value: template.id })), { name: "Cancel", value: "" }],
|
|
110
|
+
});
|
|
111
|
+
const template = templates.find((item) => item.id === choice);
|
|
112
|
+
if (!template) {
|
|
113
|
+
return fail(hint);
|
|
114
|
+
}
|
|
115
|
+
const app = await saveSettings(project, { dockerfile: template.content });
|
|
116
|
+
log.success(`${template.label} Dockerfile saved. Edit it later with \`ezhst build dockerfile set -f <file>\`.`);
|
|
117
|
+
return app;
|
|
57
118
|
};
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdtempSync, openAsBlob,
|
|
1
|
+
import { existsSync, mkdtempSync, openAsBlob, rmSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as tar from "tar";
|
|
@@ -7,7 +7,24 @@ import ora from "ora";
|
|
|
7
7
|
import { request } from "../lib/api.js";
|
|
8
8
|
import { resolveApp, resolveAppDetail } from "../lib/project.js";
|
|
9
9
|
import { fail, isJsonMode, log, output } from "../lib/ui.js";
|
|
10
|
-
|
|
10
|
+
import { ensureDockerfile } from "./build.js";
|
|
11
|
+
const IGNORED_DIRS = new Set([
|
|
12
|
+
"node_modules",
|
|
13
|
+
".next",
|
|
14
|
+
".git",
|
|
15
|
+
".vercel",
|
|
16
|
+
".turbo",
|
|
17
|
+
".swc",
|
|
18
|
+
"__pycache__",
|
|
19
|
+
".venv",
|
|
20
|
+
"venv",
|
|
21
|
+
".pytest_cache",
|
|
22
|
+
".mypy_cache",
|
|
23
|
+
"target",
|
|
24
|
+
"zig-out",
|
|
25
|
+
".zig-cache",
|
|
26
|
+
"zig-cache",
|
|
27
|
+
]);
|
|
11
28
|
const IGNORED_FILES = new Set([".DS_Store", ".easyhost.json"]);
|
|
12
29
|
const isIgnored = (entry) => {
|
|
13
30
|
const parts = entry.replace(/^\.\//, "").split("/");
|
|
@@ -20,16 +37,6 @@ const isIgnored = (entry) => {
|
|
|
20
37
|
}
|
|
21
38
|
return name.startsWith(".env") && name !== ".env.example";
|
|
22
39
|
};
|
|
23
|
-
const assertNodeProject = (cwd) => {
|
|
24
|
-
const pkgFile = path.join(cwd, "package.json");
|
|
25
|
-
if (!existsSync(pkgFile)) {
|
|
26
|
-
fail("No package.json found. Run this inside your Node.js app.");
|
|
27
|
-
}
|
|
28
|
-
const pkg = JSON.parse(readFileSync(pkgFile, "utf8"));
|
|
29
|
-
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) {
|
|
30
|
-
fail("package.json must contain a JSON object.");
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
40
|
const packSource = async (cwd) => {
|
|
34
41
|
const stage = mkdtempSync(path.join(tmpdir(), "easyhost-"));
|
|
35
42
|
const archive = path.join(stage, "app.tgz");
|
|
@@ -157,8 +164,7 @@ const finish = (project, deploymentId, url, result, cwd) => {
|
|
|
157
164
|
};
|
|
158
165
|
export const deploy = async (options) => {
|
|
159
166
|
const cwd = process.cwd();
|
|
160
|
-
|
|
161
|
-
const project = await resolveApp(options, true);
|
|
167
|
+
const project = await ensureDockerfile(await resolveApp(options, true));
|
|
162
168
|
log.info(`\nDeploying ${pc.bold(project.name)}\n`);
|
|
163
169
|
const { stage, archive } = await withSpinner("Packaging source", () => "Packaged source", () => packSource(cwd));
|
|
164
170
|
try {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createApp, deleteApp, listApps } from "./commands/apps.js";
|
|
|
6
6
|
import { createProject, deleteProject, link, listProjects, logs, projectInfo, renameProject, start, stop } from "./commands/projects.js";
|
|
7
7
|
import { deploy, deploymentLog, listDeployments, redeploy } from "./commands/deploy.js";
|
|
8
8
|
import { importEnv, listEnv, setEnv, unsetEnv } from "./commands/env.js";
|
|
9
|
-
import { resetBuild, setBuild, showBuild } from "./commands/build.js";
|
|
9
|
+
import { dockerfileTemplate, resetBuild, setBuild, setDockerfile, showBuild, showDockerfile } from "./commands/build.js";
|
|
10
10
|
import { addDomain, listDomains, removeDomain, verifyDomain } from "./commands/domains.js";
|
|
11
11
|
import { createStorage, deleteStorage, downloadStorage, listStorage, removeStorageObject, rotateStorageKeys, storageInfo, uploadStorage, } from "./commands/storage.js";
|
|
12
12
|
import { createDatabase, databaseInfo, deleteDatabase, queryDatabase, resetDatabasePassword, tableRows } from "./commands/db.js";
|
|
@@ -61,7 +61,7 @@ scoped(projects.command("info").description("Show project details")).action(proj
|
|
|
61
61
|
scoped(projects.command("rename").description("Rename a project").argument("<name>")).action(renameProject);
|
|
62
62
|
scoped(projects.command("delete").description("Delete a project and everything in it").option("--yes", "Confirm")).action(deleteProject);
|
|
63
63
|
appScoped(program.command("link").description("Link the current folder to a project")).action(link);
|
|
64
|
-
appScoped(program.command("deploy").description("Upload and deploy the
|
|
64
|
+
appScoped(program.command("deploy").description("Upload and deploy the app in this folder").option("--verbose", "Stream the build log")).action(deploy);
|
|
65
65
|
appScoped(program.command("redeploy").description("Rebuild the latest upload").option("--verbose", "Stream the build log")).action(redeploy);
|
|
66
66
|
appScoped(program.command("start").description("Start a stopped app")).action(start);
|
|
67
67
|
appScoped(program.command("stop").description("Stop the running app")).action(stop);
|
|
@@ -74,17 +74,18 @@ appScoped(env.command("list").description("List variables")).action(listEnv);
|
|
|
74
74
|
appScoped(env.command("set").description("Set variables").argument("<pairs...>", "KEY=VALUE pairs")).action(setEnv);
|
|
75
75
|
appScoped(env.command("unset").description("Remove variables").argument("<keys...>")).action(unsetEnv);
|
|
76
76
|
appScoped(env.command("import").description("Merge variables from a .env file").argument("<file>")).action(importEnv);
|
|
77
|
-
const build = program.command("build").description("Build settings
|
|
78
|
-
appScoped(build.command("show").description("Show
|
|
79
|
-
appScoped(build
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.
|
|
86
|
-
.
|
|
87
|
-
|
|
77
|
+
const build = program.command("build").description("Build settings: root directory and the Dockerfile every deploy builds with");
|
|
78
|
+
appScoped(build.command("show").description("Show the root directory and Dockerfile")).action(showBuild);
|
|
79
|
+
appScoped(build.command("set").description("Change the root directory (build context)").option("--root-dir <dir>", 'Folder with the app, relative to the project root ("" for the root)')).action(setBuild);
|
|
80
|
+
appScoped(build.command("reset").description("Clear the root directory and Dockerfile")).action(resetBuild);
|
|
81
|
+
const dockerfile = build.command("dockerfile").description("The Dockerfile stored on the app (a Dockerfile in your repo is ignored)");
|
|
82
|
+
appScoped(dockerfile.command("show").description("Print the Dockerfile")).action(showDockerfile);
|
|
83
|
+
appScoped(dockerfile.command("set").description("Save a Dockerfile").requiredOption("-f, --file <path>", 'Dockerfile to upload ("-" reads stdin)')).action(setDockerfile);
|
|
84
|
+
appScoped(dockerfile
|
|
85
|
+
.command("template")
|
|
86
|
+
.description("List templates, print one, or save one with --apply")
|
|
87
|
+
.argument("[id]", "node, bun, python, go, ruby, php, rust or zig")
|
|
88
|
+
.option("--apply", "Save the template as the app's Dockerfile")).action(dockerfileTemplate);
|
|
88
89
|
const domains = program.command("domains").description("Custom domains");
|
|
89
90
|
appScoped(domains.command("list").description("List domains and the DNS target")).action(listDomains);
|
|
90
91
|
appScoped(domains.command("add").description("Add a domain").argument("<hostname>")).action(addDomain);
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: easyhost
|
|
3
|
-
description: Deploy and manage apps on Reverhost (free hosting) with the ezhst CLI. Use when the user asks to deploy, host, publish or ship a
|
|
3
|
+
description: Deploy and manage apps on Reverhost (free hosting) with the ezhst CLI. Use when the user asks to deploy, host, publish or ship an app (any language, built from a Dockerfile) to Reverhost, or to manage its environment variables, build settings, logs, custom domains, S3 storage or Postgres database.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Reverhost
|
|
7
7
|
|
|
8
|
-
Reverhost is free hosting for
|
|
8
|
+
Reverhost is free hosting for apps in any language, built from a Dockerfile you write, with built-in S3 storage and Postgres. It is in beta. Everything is done through the `ezhst` CLI. Run it with `npx ezhst <command>` (or `ezhst` if installed globally with `npm i -g ezhst`).
|
|
9
9
|
|
|
10
10
|
## Rules for agents
|
|
11
11
|
|
|
@@ -36,12 +36,19 @@ npx ezhst link --project <slug> --json
|
|
|
36
36
|
|
|
37
37
|
## 3. Deploy
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Every app builds from a Dockerfile stored on the app (a Dockerfile in the repo is ignored, so upload it explicitly). Run inside the app folder:
|
|
40
|
+
|
|
41
|
+
1. Inspect the repo and write a `Dockerfile` (start from `npx ezhst build dockerfile template <id>`; ids: node, bun, python, go, ruby, php, rust, zig).
|
|
42
|
+
2. The app must listen on `0.0.0.0` and `$PORT` (3000).
|
|
43
|
+
3. Env vars are runtime env. If the build step needs them, use `RUN --mount=type=secret,id=appenv,target=/run/secrets/appenv sh -c 'set -a; . /run/secrets/appenv; set +a; <build command>'`. Never put secrets in `ARG` or `ENV`.
|
|
44
|
+
4. Keep the image under 1 GB (slim bases, multi-stage builds for compiled languages). Containers get 256 MB of memory and half a CPU.
|
|
45
|
+
5. Do not use `# syntax=` lines or images from the Reverhost registry; they are rejected.
|
|
40
46
|
|
|
41
47
|
```
|
|
42
48
|
npx ezhst apps create <name> --project <project-slug> --json
|
|
43
49
|
npx ezhst link --project <project-slug> --app <app-slug> --json
|
|
44
50
|
npx ezhst env import .env --json
|
|
51
|
+
npx ezhst build dockerfile set -f Dockerfile --json
|
|
45
52
|
npx ezhst deploy --json
|
|
46
53
|
```
|
|
47
54
|
|
|
@@ -55,7 +62,9 @@ Common fixes:
|
|
|
55
62
|
- Missing env var at build time: `ezhst env set KEY=VALUE`, then `ezhst redeploy`.
|
|
56
63
|
- `npm ci` says the lockfile is out of sync: delete `node_modules` and `package-lock.json`, run `npm install`, deploy again.
|
|
57
64
|
- Monorepo: `ezhst build set --root-dir apps/web`.
|
|
58
|
-
-
|
|
65
|
+
- Build fails: fix the Dockerfile, `ezhst build dockerfile set -f Dockerfile`, then `ezhst redeploy` (rebuilds the last upload, even a failed one).
|
|
66
|
+
- App starts but the URL fails: it is not listening on `0.0.0.0:$PORT`.
|
|
67
|
+
- Daily build limit reached (10 per day on Free, 50 on Pro): wait or upgrade; do not loop deploys.
|
|
59
68
|
|
|
60
69
|
After changing env vars or build settings, run `npx ezhst redeploy --json` (rebuilds the last upload). After changing code, run `deploy` again.
|
|
61
70
|
|
|
@@ -70,8 +79,8 @@ Projects and runtime:
|
|
|
70
79
|
|
|
71
80
|
Environment and build:
|
|
72
81
|
- `env list | set KEY=VALUE... | unset KEY... | import <file>`
|
|
73
|
-
- `build show`, `build set
|
|
74
|
-
-
|
|
82
|
+
- `build show`, `build set --root-dir <dir>` (build context, `""` for the project root), `build reset`
|
|
83
|
+
- `build dockerfile show`, `build dockerfile set -f <file>` (`-` reads stdin), `build dockerfile template [id] [--apply]`
|
|
75
84
|
|
|
76
85
|
Custom domains:
|
|
77
86
|
- `domains list | add <hostname> | verify <hostname> | remove <hostname>`
|