@cybermem/cli 0.13.5 → 0.13.6
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/install.js
CHANGED
|
@@ -102,7 +102,13 @@ async function install(options) {
|
|
|
102
102
|
const envType = isStaging ? "staging" : "prod";
|
|
103
103
|
const useTailscale = !!options.remoteAccess;
|
|
104
104
|
const networkType = target === "local" ? "" : useTailscale ? "ts" : "lan";
|
|
105
|
-
const envLabel = [
|
|
105
|
+
const envLabel = [
|
|
106
|
+
target === "local" ? "localhost" : target,
|
|
107
|
+
networkType,
|
|
108
|
+
envType,
|
|
109
|
+
]
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join("-");
|
|
106
112
|
console.log(chalk_1.default.blue(`Initializing CyberMem (${envLabel})...`));
|
|
107
113
|
try {
|
|
108
114
|
// Resolve Template Directory (Support both Dev and Prod)
|
|
@@ -320,8 +326,6 @@ async function install(options) {
|
|
|
320
326
|
if (!host) {
|
|
321
327
|
throw new Error("Invalid SSH Host format. Use user@host");
|
|
322
328
|
}
|
|
323
|
-
// 3. Build images locally from source
|
|
324
|
-
console.log(chalk_1.default.blue("Building Docker images locally..."));
|
|
325
329
|
let composeCmd = ["docker-compose"];
|
|
326
330
|
try {
|
|
327
331
|
await (0, execa_1.default)("docker", ["compose", "version"]);
|
|
@@ -330,46 +334,56 @@ async function install(options) {
|
|
|
330
334
|
catch (e) {
|
|
331
335
|
// Fallback to v1 if v2 not found
|
|
332
336
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
composeFile,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
handleExecError(e, "Local image build");
|
|
337
|
+
// 3. Build images locally from source (Only if --build is specified)
|
|
338
|
+
if (options.build) {
|
|
339
|
+
console.log(chalk_1.default.blue("Building Docker images locally..."));
|
|
340
|
+
try {
|
|
341
|
+
await (0, execa_1.default)(composeCmd[0], [...composeCmd.slice(1), "-f", composeFile, "build"], {
|
|
342
|
+
stdio: "inherit",
|
|
343
|
+
env: {
|
|
344
|
+
...process.env,
|
|
345
|
+
CYBERMEM_ENV: envType,
|
|
346
|
+
PROJECT_NAME: isStaging ? "cybermem-staging" : "cybermem",
|
|
347
|
+
TRAEFIK_PORT: isStaging ? "8625" : "8626",
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
catch (e) {
|
|
352
|
+
handleExecError(e, "Local image build");
|
|
353
|
+
}
|
|
351
354
|
}
|
|
352
|
-
// 4. Transfer built images to remote host
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
355
|
+
// 4. Transfer built images to remote host (Only if --build is specified)
|
|
356
|
+
if (options.build) {
|
|
357
|
+
console.log(chalk_1.default.blue(`Transferring images to ${host}...`));
|
|
358
|
+
// Get list of built images from compose file (filter cybermem-* only)
|
|
359
|
+
try {
|
|
360
|
+
const { stdout: allImages } = await (0, execa_1.default)(composeCmd[0], [
|
|
361
|
+
...composeCmd.slice(1),
|
|
362
|
+
"-f",
|
|
363
|
+
composeFile,
|
|
364
|
+
"config",
|
|
365
|
+
"--images",
|
|
366
|
+
]);
|
|
367
|
+
const builtImages = allImages
|
|
368
|
+
.trim()
|
|
369
|
+
.split("\n")
|
|
370
|
+
.filter((img) => img.includes("cybermem-"));
|
|
371
|
+
if (builtImages.length === 0) {
|
|
372
|
+
throw new Error("No cybermem images found after build");
|
|
373
|
+
}
|
|
374
|
+
console.log(chalk_1.default.gray(` Transferring ${builtImages.length} images...`));
|
|
375
|
+
await (0, execa_1.default)("bash", [
|
|
376
|
+
"-c",
|
|
377
|
+
`docker save ${builtImages.join(" ")} | ssh -o StrictHostKeyChecking=no ${sshHost} docker load`,
|
|
378
|
+
], { stdio: "inherit" });
|
|
379
|
+
console.log(chalk_1.default.green(" ✅ Images transferred"));
|
|
380
|
+
}
|
|
381
|
+
catch (e) {
|
|
382
|
+
handleExecError(e, "Image transfer");
|
|
363
383
|
}
|
|
364
|
-
console.log(chalk_1.default.gray(` Transferring ${builtImages.length} images...`));
|
|
365
|
-
await (0, execa_1.default)("bash", [
|
|
366
|
-
"-c",
|
|
367
|
-
`docker save ${builtImages.join(" ")} | ssh -o StrictHostKeyChecking=no ${sshHost} docker load`,
|
|
368
|
-
], { stdio: "inherit" });
|
|
369
|
-
console.log(chalk_1.default.green(" ✅ Images transferred"));
|
|
370
384
|
}
|
|
371
|
-
|
|
372
|
-
|
|
385
|
+
else {
|
|
386
|
+
console.log(chalk_1.default.gray(" Skipping local build/transfer (pulling from GHCR)"));
|
|
373
387
|
}
|
|
374
388
|
// 5. Resolve Ansible Paths
|
|
375
389
|
const playbookPath = path_1.default.join(templateDir, "ansible/playbooks/deploy-cybermem.yml");
|
|
@@ -390,7 +404,7 @@ async function install(options) {
|
|
|
390
404
|
"--extra-vars",
|
|
391
405
|
`ansible_ssh_extra_args='-o StrictHostKeyChecking=no'`,
|
|
392
406
|
"--extra-vars",
|
|
393
|
-
`skip_pull
|
|
407
|
+
`skip_pull=${!!options.build}`,
|
|
394
408
|
"--extra-vars",
|
|
395
409
|
`auth_token_hash=${tokenHash}`,
|
|
396
410
|
"--extra-vars",
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ program
|
|
|
23
23
|
.option("--staging", "Deploy to staging environment (different ports/data)")
|
|
24
24
|
.option("--remote-access", "Enable Tailscale Funnel for HTTPS remote access")
|
|
25
25
|
.option("--host <host>", "SSH host for remote deploy (e.g. pi@raspberrypi.local)")
|
|
26
|
+
.option("--build", "Force local image build and transfer (default: false)")
|
|
26
27
|
.action(install_1.install);
|
|
27
28
|
// Command: Uninstall
|
|
28
29
|
program
|
|
@@ -199,9 +199,8 @@
|
|
|
199
199
|
- name: Verify Overall System Health
|
|
200
200
|
uri:
|
|
201
201
|
url: "http://localhost:{{ EFFECTIVE_TRAEFIK_PORT }}/api/health"
|
|
202
|
-
return_content: true
|
|
203
202
|
register: health_status
|
|
204
|
-
until: "health_status.
|
|
203
|
+
until: "health_status.json is defined and health_status.json.overall == 'ok'"
|
|
205
204
|
retries: 5
|
|
206
205
|
delay: 10
|
|
207
206
|
ignore_errors: true
|
package/package.json
CHANGED
|
@@ -199,9 +199,8 @@
|
|
|
199
199
|
- name: Verify Overall System Health
|
|
200
200
|
uri:
|
|
201
201
|
url: "http://localhost:{{ EFFECTIVE_TRAEFIK_PORT }}/api/health"
|
|
202
|
-
return_content: true
|
|
203
202
|
register: health_status
|
|
204
|
-
until: "health_status.
|
|
203
|
+
until: "health_status.json is defined and health_status.json.overall == 'ok'"
|
|
205
204
|
retries: 5
|
|
206
205
|
delay: 10
|
|
207
206
|
ignore_errors: true
|