@ours.network/install 1.2.1-nightly.14 → 1.2.1-nightly.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.
- package/README.md +71 -0
- package/ROOTLESS_PODMAN_VALIDATION.md +210 -0
- package/assets/Dockerfile.gateway +3 -2
- package/assets/gateway-entrypoint.sh +37 -0
- package/assets/release-lock.json +10 -10
- package/assets/release.json +3 -3
- package/assets/scripts/maintenance/docker-layout-conversion.mjs +4 -2
- package/assets/sources.json +4 -4
- package/lib/container-engine.mjs +127 -0
- package/lib/docker-conversion-runtime.mjs +3 -2
- package/lib/docker-layout-installation.mjs +2 -1
- package/lib/docker-runtime-repair.mjs +8 -7
- package/lib/effects.mjs +115 -51
- package/lib/gateway.mjs +1 -1
- package/lib/legacy-migration.mjs +13 -2
- package/lib/orchestrate.mjs +2 -1
- package/lib/plan.mjs +5 -2
- package/lib/podman-preflight.mjs +40 -0
- package/lib/setup-options.mjs +2 -1
- package/lib/setup.mjs +1 -0
- package/lib/target.mjs +3 -2
- package/lib/usage.mjs +1 -0
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runContainer } from './container-engine.mjs';
|
|
1
2
|
/** Qualify cached images before reuse; repair only the known root-owned 0600 policy. */
|
|
2
3
|
import { lstatSync, readFileSync, writeFileSync, mkdtempSync, rmSync, realpathSync, openSync, closeSync, fstatSync, fchmodSync, constants } from 'node:fs';
|
|
3
4
|
import { join } from 'node:path';
|
|
@@ -66,7 +67,7 @@ export async function qualifyDockerRuntime(record, effects) {
|
|
|
66
67
|
if (![uid, gid].every(n => Number.isInteger(n) && n > 0)) fail('non-root runtime UID/GID required');
|
|
67
68
|
const tag = `${record.project}:runtime`;
|
|
68
69
|
const inspect = async target => {
|
|
69
|
-
const { stdout } = await effects
|
|
70
|
+
const { stdout } = await runContainer(effects, record, ['image', 'inspect', target], { timeout: 60000 });
|
|
70
71
|
const [value] = JSON.parse(stdout);
|
|
71
72
|
if (!imageId(value?.Id) || !Array.isArray(value.RootFS?.Layers) || value.Config?.Labels?.['network.ours.build-context'] !== '1') fail('image lacks recognized build metadata');
|
|
72
73
|
return value;
|
|
@@ -74,13 +75,13 @@ export async function qualifyDockerRuntime(record, effects) {
|
|
|
74
75
|
const probe = async (id, user) => {
|
|
75
76
|
const name = `ours-runtime-probe-${randomUUID()}`;
|
|
76
77
|
try {
|
|
77
|
-
const result = await effects
|
|
78
|
+
const result = await runContainer(effects, record, ['run', '--rm', '--name', name, '--read-only', '--network', 'none', '--cap-drop', 'ALL',
|
|
78
79
|
'--security-opt', 'no-new-privileges:true', '--pids-limit', '64', '--memory', '256m', '--user', user, '--entrypoint', 'node', id, '-e', probeScript],
|
|
79
80
|
{ allowCodes: [1, 74], timeout: 60000 });
|
|
80
81
|
return { code: result.code, report: result.code === 0 ? JSON.parse(result.stdout) : null };
|
|
81
82
|
} catch (error) {
|
|
82
83
|
// A killed Docker client can leave its own bounded probe container behind.
|
|
83
|
-
try { await effects
|
|
84
|
+
try { await runContainer(effects, record, ['rm', '-f', name], { allowCodes: [1], timeout: 10000 }); } catch {}
|
|
84
85
|
throw error;
|
|
85
86
|
}
|
|
86
87
|
};
|
|
@@ -101,11 +102,11 @@ export async function qualifyDockerRuntime(record, effects) {
|
|
|
101
102
|
try {
|
|
102
103
|
// Unique local alias transports the immutable ID into BuildKit. The resulting
|
|
103
104
|
// layer ancestry and complete execution config are checked before publication.
|
|
104
|
-
await effects
|
|
105
|
+
await runContainer(effects, record, ['image', 'tag', original.Id, baseTag]);
|
|
105
106
|
if ((await inspect(baseTag)).Id !== original.Id) fail('repair base image changed');
|
|
106
107
|
writeFileSync(join(directory, 'sources.json'), policy, { mode: 0o600, flag: 'wx' });
|
|
107
108
|
writeFileSync(join(directory, 'Dockerfile'), `FROM ${baseTag}\nCOPY --chmod=644 sources.json ${policyPath}\n`, { mode: 0o600, flag: 'wx' });
|
|
108
|
-
await effects
|
|
109
|
+
await runContainer(effects, record, ['build', '--network=none', '--pull=false', '--tag', candidateTag, directory], { stream: true, timeout: 120000 });
|
|
109
110
|
const candidate = await inspect(candidateTag);
|
|
110
111
|
if (!isDeepStrictEqual(candidate.Config, original.Config) || !isDeepStrictEqual(candidate.RootFS.Layers.slice(0, original.RootFS.Layers.length), original.RootFS.Layers)
|
|
111
112
|
|| candidate.RootFS.Layers.length !== original.RootFS.Layers.length + 1) fail('repair changed image execution settings or ancestry');
|
|
@@ -114,11 +115,11 @@ export async function qualifyDockerRuntime(record, effects) {
|
|
|
114
115
|
check(verified.report, 0o644);
|
|
115
116
|
if (!isDeepStrictEqual(verified.report.records, privileged.report.records)) fail('repair changed build provenance');
|
|
116
117
|
if ((await inspect(tag)).Id !== original.Id) fail('selected image changed during repair; retry setup');
|
|
117
|
-
await effects
|
|
118
|
+
await runContainer(effects, record, ['image', 'tag', candidate.Id, tag]);
|
|
118
119
|
effects.out?.('Cached Docker image repaired and verified; continuing setup.');
|
|
119
120
|
} finally {
|
|
120
121
|
for (const temporary of [candidateTag, baseTag]) {
|
|
121
|
-
try { await effects
|
|
122
|
+
try { await runContainer(effects, record, ['image', 'rm', temporary], { allowCodes: [1], timeout: 10000 }); } catch {}
|
|
122
123
|
}
|
|
123
124
|
rmSync(directory, { recursive: true, force: true });
|
|
124
125
|
}
|
package/lib/effects.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { qualifyPodman } from './podman-preflight.mjs';
|
|
2
|
+
import { engineName, bindPodman, runContainer, nativeBuildCommands } from './container-engine.mjs';
|
|
1
3
|
// ours-install v3 — the real side effects.
|
|
2
4
|
//
|
|
3
5
|
// Every mutation the installer can perform lives here and nowhere else, behind
|
|
@@ -551,14 +553,54 @@ export function networkEffects(effects) {
|
|
|
551
553
|
record.schema === 1 && existsSync(join(record.workDir, 'docker-compose.legacy.yaml'))
|
|
552
554
|
? 'docker-compose.legacy.yaml' : 'docker-compose.yaml'),
|
|
553
555
|
...(record.gateway ? ['--file', join(record.workDir, 'docker-compose.gateway.yaml')] : []),
|
|
556
|
+
...(engineName(record) === 'podman' ? ['--file', join(record.workDir, 'compose.podman.json')] : []),
|
|
554
557
|
'--project-name', record.project, ...args,
|
|
555
558
|
];
|
|
556
|
-
const
|
|
557
|
-
|
|
559
|
+
const container = (record, args, options = {}) => runContainer(effects, record, args, options);
|
|
560
|
+
const compose = async (record, args, options = {}) => {
|
|
561
|
+
const selected = { ...options, env: { ...baseEnv(record), ...options.env } };
|
|
562
|
+
if (engineName(record) === 'podman' && args[0] === 'build') {
|
|
563
|
+
const result = await container(record, composeArgs(record, ['--profile', '*', 'config', '--format', 'json']), { env: selected.env });
|
|
564
|
+
for (const command of nativeBuildCommands(JSON.parse(result.stdout), args.slice(1), { ...env, ...selected.env })) await container(record, command, selected);
|
|
565
|
+
return { code: 0, stdout: '' };
|
|
566
|
+
}
|
|
567
|
+
if (engineName(record) === 'podman' && ['run', 'up'].includes(args[0])) {
|
|
568
|
+
const resolved = JSON.parse((await container(record, composeArgs(record, ['--profile', '*', 'config', '--format', 'json']), { env: selected.env })).stdout);
|
|
569
|
+
for (const [key, volume] of Object.entries(resolved.volumes ?? {})) {
|
|
570
|
+
if (volume.external) throw new Error('Unexpected external installation volume');
|
|
571
|
+
const name = volume.name ?? `${record.project}_${key}`;
|
|
572
|
+
const found = await container(record, ['volume', 'inspect', '--format', '{{json .}}', name], { allowCodes: [1] });
|
|
573
|
+
if (found.code === 1) continue;
|
|
574
|
+
const value = JSON.parse(found.stdout);
|
|
575
|
+
if (value.Name !== name || value.Labels?.['com.docker.compose.project'] !== record.project || value.Labels?.['com.docker.compose.volume'] !== key) throw new Error(`Refusing foreign volume: ${name}`);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
// Compose run can implicitly build an absent administration image. Build
|
|
579
|
+
// its resolved target natively first, just like explicit build operations.
|
|
580
|
+
if (engineName(record) === 'podman' && args[0] === 'run') {
|
|
581
|
+
const resolved = JSON.parse((await container(record, composeArgs(record, ['--profile', '*', 'config', '--format', 'json']), { env: selected.env })).stdout);
|
|
582
|
+
const takesValue = new Set(['--name', '--entrypoint', '--env', '-e', '--user', '-u', '--workdir', '-w', '--volume', '-v', '--publish', '-p', '--label', '-l', '--pull']);
|
|
583
|
+
let name;
|
|
584
|
+
for (let i = 1; i < args.length; i++) {
|
|
585
|
+
if (takesValue.has(args[i])) { i++; continue; }
|
|
586
|
+
if (args[i].startsWith('-')) continue;
|
|
587
|
+
name = args[i]; break;
|
|
588
|
+
}
|
|
589
|
+
const service = resolved.services?.[name];
|
|
590
|
+
if (!service) throw new Error(`Unresolved Podman administration service: ${name}`);
|
|
591
|
+
if (service.build) {
|
|
592
|
+
const image = await container(record, ['image', 'inspect', service.image], { allowCodes: [1] });
|
|
593
|
+
if (image.code === 1) for (const command of nativeBuildCommands(resolved, [name], { ...env, ...selected.env })) await container(record, command, selected);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return container(record, composeArgs(record, args), selected);
|
|
597
|
+
};
|
|
558
598
|
const dockerStartupError = async (record, service, cause) => {
|
|
559
599
|
const args = ['logs', '--no-color', '--tail', '50', '--timestamps', service];
|
|
560
600
|
const quote = value => `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
561
|
-
const
|
|
601
|
+
const engine = engineName(record);
|
|
602
|
+
const prefix = engine === 'podman' ? ['--remote', '--url', `unix://${record.containerBinding.socket}`] : [];
|
|
603
|
+
const command = `OURS_DAEMON_ID=${quote(record.instanceId)} ${engine} ${[...prefix, ...composeArgs(record, args)].map(quote).join(' ')}`;
|
|
562
604
|
let detail;
|
|
563
605
|
try {
|
|
564
606
|
const logs = await compose(record, args);
|
|
@@ -569,7 +611,7 @@ export function networkEffects(effects) {
|
|
|
569
611
|
} catch {
|
|
570
612
|
detail = 'Container logs could not be read.';
|
|
571
613
|
}
|
|
572
|
-
return new Error(
|
|
614
|
+
return new Error(`${engine === 'podman' ? 'Podman' : 'Docker'} service "${service}" failed to start or become healthy.\n${detail}\nStartup error: ${cause.message}\nInspect logs: ${command}`, { cause });
|
|
573
615
|
};
|
|
574
616
|
const bin = (record, name) => join(record.workDir, 'node_modules', '.bin', name);
|
|
575
617
|
const localEnv = (record, service = 'daemon') => {
|
|
@@ -591,7 +633,7 @@ export function networkEffects(effects) {
|
|
|
591
633
|
const requireCleanContainerExit = async (record, selected) => {
|
|
592
634
|
const containers = await compose(record, ['ps', '-aq', ...selected]);
|
|
593
635
|
for (const id of containers.stdout.split(/\s+/).filter(Boolean)) {
|
|
594
|
-
const result = await
|
|
636
|
+
const result = await container(record, ['inspect', '--format', '{{json .State}}', id]);
|
|
595
637
|
const state = JSON.parse(result.stdout);
|
|
596
638
|
if (state.Status !== 'exited' || state.ExitCode !== 0 || state.OOMKilled !== false || state.Dead !== false) {
|
|
597
639
|
throw new Error('Selected source container did not stop cleanly; state operation refused');
|
|
@@ -625,7 +667,7 @@ export function networkEffects(effects) {
|
|
|
625
667
|
return version;
|
|
626
668
|
});
|
|
627
669
|
},
|
|
628
|
-
newInstallation(root, mode) {
|
|
670
|
+
newInstallation(root, mode, { containerEngine } = {}) {
|
|
629
671
|
if (existsSync(root)) {
|
|
630
672
|
privateDirectory(root);
|
|
631
673
|
if (readdirSync(root).some(name => name !== '.operation.lock')) throw new Error('Installation root is not empty and has no selection record');
|
|
@@ -633,7 +675,7 @@ export function networkEffects(effects) {
|
|
|
633
675
|
const instanceId = env.OURS_DAEMON_ID || randomUUID();
|
|
634
676
|
if (!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(instanceId)) throw new Error('OURS_DAEMON_ID must be a lowercase UUID');
|
|
635
677
|
const project = `ours-${createHash('sha256').update(root).digest('hex').slice(0, 16)}`;
|
|
636
|
-
return { schema: 2, root, mode, instanceId, project, workDir: join(root, 'runtime'), configPath: installationPaths({ schema: 2, root }).config, sourcesPath: join(root, 'sources.json'), services: [...SERVER_SERVICES, ...(mode === 'docker' ? ['gateway'] : [])], ...(mode === 'docker' ? { gateway: { version: 1 } } : {}), port: 3050, coworkPort: 3052, messengerPort: 8420, messengerIdentity: env.OURS_MESSENGER_IDENTITY || null, uid: 1000, gid: 1000 };
|
|
678
|
+
return { schema: 2, root, mode, ...(containerEngine ? { containerEngine } : {}), instanceId, project, workDir: join(root, 'runtime'), configPath: installationPaths({ schema: 2, root }).config, sourcesPath: join(root, 'sources.json'), services: [...SERVER_SERVICES, ...(mode === 'docker' ? ['gateway'] : [])], ...(mode === 'docker' ? { gateway: { version: 1 } } : {}), port: 3050, coworkPort: 3052, messengerPort: 8420, messengerIdentity: env.OURS_MESSENGER_IDENTITY || null, uid: 1000, gid: 1000 };
|
|
637
679
|
},
|
|
638
680
|
async serverPreflight(record, operation, { existing, sourcePath = record.sourcesPath, sourceManifest, identityName } = {}) {
|
|
639
681
|
if (existing) {
|
|
@@ -643,37 +685,55 @@ export function networkEffects(effects) {
|
|
|
643
685
|
if (env.OURS_DAEMON_ID && env.OURS_DAEMON_ID !== record.instanceId) throw new Error('Conflicting instance ID');
|
|
644
686
|
}
|
|
645
687
|
if (record.mode === 'docker') {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
688
|
+
if (engineName(record) === 'podman') {
|
|
689
|
+
await bindPodman(effects, record);
|
|
690
|
+
if (['install', 'start', 'restart', 'update', 'rebuild', 'gateway-enable'].includes(operation)) {
|
|
691
|
+
const userHome = userInfo().homedir;
|
|
692
|
+
for (const [key, expected] of Object.entries({ HOME: userHome, XDG_CONFIG_HOME: join(userHome, '.config'), XDG_DATA_HOME: join(userHome, '.local/share'), XDG_RUNTIME_DIR: `/run/user/${process.getuid()}` })) {
|
|
693
|
+
if (env[key] && env[key] !== expected) throw new Error(`${key} selects a custom Podman environment that the standard boot service does not retain`);
|
|
694
|
+
}
|
|
695
|
+
if (record.containerBinding.socket !== `/run/user/${process.getuid()}/podman/podman.sock`) throw new Error('The standard user boot service requires the default local Podman socket');
|
|
696
|
+
await effects.run('systemctl', ['--user', 'is-enabled', 'podman.socket']);
|
|
697
|
+
await effects.run('systemctl', ['--user', 'is-enabled', 'podman-restart.service']);
|
|
698
|
+
const restart = await effects.run('systemctl', ['--user', 'show', 'podman-restart.service', '--property=ExecStart', '--value']);
|
|
699
|
+
if (!/--filter[ =]+should-start-on-boot=true(?:[ ;}]|$)/.test(restart.stdout)) throw new Error('Installed podman-restart.service cannot recover unless-stopped workloads; use a Podman release with should-start-on-boot support');
|
|
700
|
+
const linger = await effects.run('loginctl', ['show-user', String(process.getuid()), '--property=Linger', '--value']);
|
|
701
|
+
if (linger.stdout.trim() !== 'yes') throw new Error('Rootless server requires user linger for logout/reboot recovery; ask your administrator to enable it');
|
|
702
|
+
await qualifyPodman(effects, record);
|
|
703
|
+
}
|
|
704
|
+
} else {
|
|
705
|
+
const nativeRoot = existing ? '/path/to/new-empty-directory' : record.root;
|
|
706
|
+
const quotedRoot = `'${String(nativeRoot).replaceAll("'", "'\\''")}'`;
|
|
707
|
+
const quotedName = `'${String(identityName ?? record.messengerIdentity ?? 'Your Name').replaceAll("'", "'\\''")}'`;
|
|
708
|
+
const recovery = [
|
|
709
|
+
'Please install Docker Desktop on macOS/Windows, or Docker Engine with the Compose plugin on Linux, and start Docker before retrying.',
|
|
710
|
+
'Docker is recommended for macOS and Windows.',
|
|
711
|
+
`Alternatively, use native installation: ours-install server install --mode packages --state-dir ${quotedRoot} --identity-name ${quotedName}`,
|
|
712
|
+
'Native mode requires systemd user services on Linux/WSL or a launchd GUI session on macOS.',
|
|
713
|
+
...(existing ? ['Keep this existing Docker installation in Docker mode; use a separate empty directory for a new native installation.'] : []),
|
|
714
|
+
].join('\n');
|
|
715
|
+
try {
|
|
716
|
+
await container(record, ['info', '--format', '{{.ServerVersion}}']);
|
|
717
|
+
} catch (cause) {
|
|
718
|
+
const problem = cause.code === 'ENOENT'
|
|
719
|
+
? 'Docker command was not found in PATH.'
|
|
720
|
+
: `Docker Engine is not reachable. Start Docker and check that your user can access it.\nDetails: ${cause.message}`;
|
|
721
|
+
throw new Error(`${problem}\n${recovery}`, { cause });
|
|
722
|
+
}
|
|
723
|
+
let version;
|
|
724
|
+
try {
|
|
725
|
+
version = await container(record, ['compose', 'version', '--short']);
|
|
726
|
+
} catch (cause) {
|
|
727
|
+
throw new Error(`Docker Compose 2.35 or newer is required, but the Compose plugin could not run. Update Docker Desktop or install the Docker Compose plugin.\n${recovery}`, { cause });
|
|
728
|
+
}
|
|
729
|
+
const match = /^v?(\d+)\.(\d+)/.exec(version.stdout.trim());
|
|
730
|
+
if (!match || Number(match[1]) < 2 || (Number(match[1]) === 2 && Number(match[2]) < 35)) {
|
|
731
|
+
throw new Error(`Docker Compose 2.35 or newer is required. Update Docker Desktop or the Docker Compose plugin.\n${recovery}`);
|
|
732
|
+
}
|
|
673
733
|
}
|
|
674
734
|
if (operation !== 'status') {
|
|
675
735
|
// Compose clients can disappear while their Engine-owned command continues.
|
|
676
|
-
const active = await
|
|
736
|
+
const active = await container(record, ['ps', '--filter', `label=com.docker.compose.project=${record.project}`, '--filter', 'label=com.docker.compose.oneoff=True', '--format', '{{.ID}}']);
|
|
677
737
|
if (active.stdout.trim()) throw new Error('Another server installation operation is still running in Docker');
|
|
678
738
|
}
|
|
679
739
|
} else {
|
|
@@ -715,6 +775,7 @@ export function networkEffects(effects) {
|
|
|
715
775
|
async prepareGateway(record) {
|
|
716
776
|
atomicWriteConfig(join(record.workDir, 'docker-compose.gateway.yaml'), gatewayCompose(record));
|
|
717
777
|
atomicWriteConfig(join(record.workDir, 'nginx.conf'), gatewayNginx(record));
|
|
778
|
+
atomicWriteConfig(join(record.workDir, 'gateway-entrypoint.sh'), readFileSync(join(INSTALLER_ASSETS, 'gateway-entrypoint.sh'), 'utf8'));
|
|
718
779
|
atomicWriteConfig(join(record.workDir, 'Dockerfile.gateway'), readFileSync(join(INSTALLER_ASSETS, 'Dockerfile.gateway'), 'utf8'));
|
|
719
780
|
await compose(record, ['build', 'gateway'], { stream: true, env: { BUILDKIT_PROGRESS: 'plain' } });
|
|
720
781
|
},
|
|
@@ -743,7 +804,7 @@ export function networkEffects(effects) {
|
|
|
743
804
|
['messenger-server', ['capabilities'], 'messenger.gateway-prefix-v1'],
|
|
744
805
|
['tg-connector', ['capabilities'], 'telegram.gateway-listener-v1'],
|
|
745
806
|
]) {
|
|
746
|
-
const probe = await
|
|
807
|
+
const probe = await container(record, ['run', '--rm', '--network', 'none', '--read-only', '--entrypoint', 'node', `${record.project}:runtime`, `/opt/ours/node_modules/@ours.network/${name}/dist/cli.js`, ...args]);
|
|
747
808
|
let value; try { value = JSON.parse(probe.stdout); } catch {}
|
|
748
809
|
const capabilities = value?.result?.capabilities ?? value?.capabilities;
|
|
749
810
|
if (!Array.isArray(capabilities) || !capabilities.includes(capability))
|
|
@@ -763,15 +824,17 @@ export function networkEffects(effects) {
|
|
|
763
824
|
if (!existsSync(materialized)) writePrivateNew(materialized, retained);
|
|
764
825
|
else if (!readFileSync(materialized).equals(retained)) throw new Error('Materialized sources differ from retained selection');
|
|
765
826
|
if (record.mode === 'docker') {
|
|
827
|
+
if (engineName(record) === 'podman') atomicWriteConfig(join(record.workDir, 'compose.podman.json'), JSON.stringify({ services: Object.fromEntries(record.services.map(name => [name, { restart: 'unless-stopped' }])) }));
|
|
766
828
|
refreshDockerPolicyCopy(record);
|
|
767
829
|
if (record.gateway) {
|
|
768
830
|
atomicWriteConfig(join(record.workDir, 'docker-compose.gateway.yaml'), gatewayCompose(record));
|
|
769
831
|
atomicWriteConfig(join(record.workDir, 'nginx.conf'), gatewayNginx(record));
|
|
832
|
+
for (const file of ['Dockerfile.gateway', 'gateway-entrypoint.sh']) atomicWriteConfig(join(record.workDir, file), readFileSync(join(INSTALLER_ASSETS, file), 'utf8'));
|
|
770
833
|
}
|
|
771
834
|
// The installer owns these dependencies in both installation modes.
|
|
772
835
|
const { dependencies } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
773
836
|
writeFileSync(join(record.workDir, 'scripts/maintenance/package.json'), JSON.stringify({ private: true, type: 'module', dependencies }, null, 2) + '\n', { mode: 0o600 });
|
|
774
|
-
const image = await
|
|
837
|
+
const image = await container(record, ['image', 'inspect', `${record.project}:runtime`], { allowCodes: [1] });
|
|
775
838
|
if (image.code !== 0) await compose(record, ['build', 'daemon'], { stream: true, env: { BUILDKIT_PROGRESS: 'plain' } });
|
|
776
839
|
await effects.qualifyDockerRuntime(record);
|
|
777
840
|
if (record.gateway) {
|
|
@@ -847,17 +910,17 @@ export function networkEffects(effects) {
|
|
|
847
910
|
},
|
|
848
911
|
async copyDockerBuildRecords(record, directory) {
|
|
849
912
|
// Inspect immutable image metadata; never reinterpret a failed context copy as legacy.
|
|
850
|
-
const label = (await
|
|
913
|
+
const label = (await container(record, ['image', 'inspect', '--format', '{{ index .Config.Labels "network.ours.build-context" }}', `${record.project}:runtime`])).stdout.trim();
|
|
851
914
|
if (!['', '<no value>', '1'].includes(label)) throw new Error('Unsupported image build-context schema');
|
|
852
915
|
const names = [...BASE_RECORDS, ...(label === '1' ? [CONTEXT] : [])];
|
|
853
916
|
const stage = mkdtempSync(join(directory, '.records-'));
|
|
854
917
|
const name = `${record.project}-records`;
|
|
855
918
|
let created = false;
|
|
856
919
|
try {
|
|
857
|
-
await
|
|
920
|
+
await container(record, ['create', '--name', name, '--entrypoint', '/bin/true', `${record.project}:runtime`]);
|
|
858
921
|
created = true;
|
|
859
922
|
for (const file of names) {
|
|
860
|
-
await
|
|
923
|
+
await container(record, ['cp', `${name}:/opt/ours/${file}`, join(stage, file)]);
|
|
861
924
|
const st = lstatSync(join(stage, file));
|
|
862
925
|
if (!st.isFile() || st.uid !== process.getuid() || (st.mode & 0o7002)) throw new Error('Unsafe copied build record');
|
|
863
926
|
chmodSync(join(stage, file), 0o600);
|
|
@@ -867,7 +930,7 @@ export function networkEffects(effects) {
|
|
|
867
930
|
for (const file of names) renameSync(join(stage, file), join(directory, file));
|
|
868
931
|
if (label !== '1' && existsSync(join(directory, CONTEXT))) throw new Error('Legacy image conflicts with retained build context');
|
|
869
932
|
} finally {
|
|
870
|
-
try { if (created) await
|
|
933
|
+
try { if (created) await container(record, ['rm', name]); }
|
|
871
934
|
finally { rmSync(stage, { recursive: true, force: true }); }
|
|
872
935
|
}
|
|
873
936
|
},
|
|
@@ -920,10 +983,10 @@ export function networkEffects(effects) {
|
|
|
920
983
|
if (record.mode === 'docker') {
|
|
921
984
|
for (const target of ['runtime', 'maintenance', ...(record.gateway ? ['gateway'] : [])]) {
|
|
922
985
|
const retained = `${candidate.project}:previous-${target}`;
|
|
923
|
-
const found = await
|
|
986
|
+
const found = await container(record, ['image', 'inspect', retained], { allowCodes: [1] });
|
|
924
987
|
if (found.code !== 0) {
|
|
925
|
-
const current = await
|
|
926
|
-
if (current.code === 0) await
|
|
988
|
+
const current = await container(record, ['image', 'inspect', `${record.project}:${target}`], { allowCodes: [1] });
|
|
989
|
+
if (current.code === 0) await container(record, ['tag', `${record.project}:${target}`, retained]);
|
|
927
990
|
}
|
|
928
991
|
}
|
|
929
992
|
}
|
|
@@ -940,7 +1003,7 @@ export function networkEffects(effects) {
|
|
|
940
1003
|
} else privateDirectory(record.workDir);
|
|
941
1004
|
if (record.mode === 'docker') {
|
|
942
1005
|
for (const target of ['runtime', 'maintenance', ...(record.gateway ? ['gateway'] : [])]) {
|
|
943
|
-
await
|
|
1006
|
+
await container(candidate, ['tag', `${candidate.project}:${target}`, `${record.project}:${target}`]);
|
|
944
1007
|
}
|
|
945
1008
|
}
|
|
946
1009
|
atomicWriteConfig(record.sourcesPath, readFileSync(candidate.sourcesPath));
|
|
@@ -956,8 +1019,8 @@ export function networkEffects(effects) {
|
|
|
956
1019
|
if (candidate.mode === 'docker') {
|
|
957
1020
|
for (const target of ['runtime', 'maintenance', 'previous-runtime', 'previous-maintenance', ...(candidate.gateway ? ['gateway', 'previous-gateway'] : [])]) {
|
|
958
1021
|
const image = `${candidate.project}:${target}`;
|
|
959
|
-
const found = await
|
|
960
|
-
if (found.code === 0) await
|
|
1022
|
+
const found = await container(candidate, ['image', 'inspect', image], { allowCodes: [1] });
|
|
1023
|
+
if (found.code === 0) await container(candidate, ['image', 'rm', image]);
|
|
961
1024
|
}
|
|
962
1025
|
}
|
|
963
1026
|
privateDirectory(candidate.root);
|
|
@@ -975,13 +1038,13 @@ export function networkEffects(effects) {
|
|
|
975
1038
|
try {
|
|
976
1039
|
await compose(record, ['run', '--name', name, '--no-deps', '-T', 'access', 'access-issue', issuedPath], { sensitive: true });
|
|
977
1040
|
const file = join(staging, 'credential');
|
|
978
|
-
await
|
|
1041
|
+
await container(record, ['cp', `${name}:${issuedPath}`, file], { sensitive: true });
|
|
979
1042
|
assertPrivateRegularFile(file, 'issued credential');
|
|
980
1043
|
// Exclusive publication never overwrites an unrelated credential.
|
|
981
1044
|
writePrivateNew(output, readFileSync(file));
|
|
982
1045
|
} finally {
|
|
983
1046
|
await compose(record, ['run', '--rm', '--no-deps', '-T', '--entrypoint', 'rm', 'access', '-f', issuedPath], { sensitive: true });
|
|
984
|
-
await
|
|
1047
|
+
await container(record, ['rm', '-f', name], { sensitive: true });
|
|
985
1048
|
rmSync(staging, { recursive: true, force: true });
|
|
986
1049
|
}
|
|
987
1050
|
return;
|
|
@@ -1051,12 +1114,12 @@ export function networkEffects(effects) {
|
|
|
1051
1114
|
if (typeof name !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(name)) {
|
|
1052
1115
|
throw new Error('Invalid conversion volume name');
|
|
1053
1116
|
}
|
|
1054
|
-
const result = await
|
|
1117
|
+
const result = await container(record, ['volume', 'inspect', '--format', '{{json .}}', name], {
|
|
1055
1118
|
...(optional ? { allowCodes: [1] } : {}),
|
|
1056
1119
|
});
|
|
1057
1120
|
if (result.code !== 0) {
|
|
1058
1121
|
if (optional) {
|
|
1059
|
-
const inventory = await
|
|
1122
|
+
const inventory = await container(record, ['volume', 'ls', '--format', '{{.Name}}']);
|
|
1060
1123
|
if (inventory.code === 0 && !inventory.stdout.split(/\s+/).includes(name)) return false;
|
|
1061
1124
|
}
|
|
1062
1125
|
throw new Error(`Source volume is missing or unavailable: ${name}`);
|
|
@@ -1190,6 +1253,7 @@ export function networkEffects(effects) {
|
|
|
1190
1253
|
try { await start(service); }
|
|
1191
1254
|
catch (error) { failures.push({ service, error }); }
|
|
1192
1255
|
}
|
|
1256
|
+
if (!failures.length && record.gateway && ['daemon', 'cowork', 'gateway'].every(service => selected.includes(service))) await effects.verifyGateway(record);
|
|
1193
1257
|
if (failures.length) throw new Error(`Application readiness failed: ${failures.map(f => f.service).join(', ')}. Check the selected application prerequisites.\n${failures.map(f => f.error.message).join('\n\n')}`);
|
|
1194
1258
|
return;
|
|
1195
1259
|
}
|
package/lib/gateway.mjs
CHANGED
|
@@ -92,7 +92,7 @@ http {
|
|
|
92
92
|
uwsgi_temp_path /tmp/uwsgi;
|
|
93
93
|
scgi_temp_path /tmp/scgi;
|
|
94
94
|
proxy_next_upstream off;
|
|
95
|
-
resolver
|
|
95
|
+
resolver @@OURS_RESOLVERS@@ valid=5s;
|
|
96
96
|
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
|
|
97
97
|
server {
|
|
98
98
|
listen 8080;
|
package/lib/legacy-migration.mjs
CHANGED
|
@@ -17,6 +17,13 @@ function readJournal(root) {
|
|
|
17
17
|
if (j.schema !== 1 || j.targetRoot !== root || !phases.includes(j.phase) || !Array.isArray(j.identities)) throw new Error('Invalid legacy migration journal');
|
|
18
18
|
return j;
|
|
19
19
|
}
|
|
20
|
+
// Legacy cutover publishes a Docker/package launcher; Podman cutover is not supported.
|
|
21
|
+
function rejectPodmanMigration(options, effects, ...records) {
|
|
22
|
+
if (options.containerEngine === 'podman' || records.some(record => record?.containerEngine === 'podman')
|
|
23
|
+
|| effects.readJson(join(options.stateDir, 'installation.json'))?.containerEngine === 'podman') {
|
|
24
|
+
throw new Error('Legacy migration to Podman is not supported. Use a fresh Podman installation or migrate with Docker/packages.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
20
27
|
function selection(source) {
|
|
21
28
|
return { env: { OURS_CONFIG: source.configPath, OURS_STATE_DIR: source.stateDir, OURS_PORT: String(source.config.port ?? 3050), OURS_API_TOKEN: undefined, OURS_DAEMON_ID: undefined, OURS_DAEMON_URL: undefined, OURS_DAEMON_CREDENTIAL_PATH: undefined }, sensitive: true };
|
|
22
29
|
}
|
|
@@ -31,10 +38,11 @@ function validateIdentities(rows, source) {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export async function inspectLegacyMigration(options, effects, deps = {}) {
|
|
41
|
+
const journal = readJournal(options.stateDir);
|
|
42
|
+
rejectPodmanMigration(options, effects, journal?.record, options.legacyPlan?.journal?.record);
|
|
34
43
|
const inspect = deps.inspectLegacyState ?? inspectLegacyState;
|
|
35
44
|
await (deps.ensureLegacyLockSupport ?? ensureLegacyLockSupport)();
|
|
36
45
|
const cliPlan = options.dryRun ? null : await (deps.inspectManagedCli ?? inspectManagedCli)(effects, options.stateDir);
|
|
37
|
-
const journal = readJournal(options.stateDir);
|
|
38
46
|
if (journal) {
|
|
39
47
|
if (journal.sourceConfig !== options.migrateFrom) throw new Error('Another legacy source is already selected for this target');
|
|
40
48
|
return { journal, cliPlan, source: journal.phase === 'complete' ? null : { ...inspect(options.migrateFrom, options.stateDir), originalProgram: cliPlan?.originalProgram } };
|
|
@@ -80,12 +88,15 @@ export async function prepareMigrationCliRuntime(record, effects) {
|
|
|
80
88
|
|
|
81
89
|
/** Called under the normal installation lock; retries never overwrite imported state. */
|
|
82
90
|
export async function executeLegacyMigration(args, effects, install, deps = {}) {
|
|
91
|
+
const retainedJournal = readJournal(args.stateDir);
|
|
92
|
+
rejectPodmanMigration(args, effects, retainedJournal?.record, args.legacyPlan?.journal?.record);
|
|
83
93
|
const stage = deps.stageLegacyState ?? stageLegacyState;
|
|
84
94
|
const lock = deps.withLegacyStateLock ?? withLegacyStateLock;
|
|
85
95
|
const save = (root, value) => (deps.atomicWriteConfig ?? atomicWriteConfig)(journalPath(root), JSON.stringify(value, null, 2) + '\n');
|
|
86
96
|
const prepareCli = deps.prepareMigrationCliRuntime ?? prepareMigrationCliRuntime;
|
|
87
97
|
const inspected = args.legacyPlan ?? await inspectLegacyMigration(args, effects, deps);
|
|
88
|
-
let journal =
|
|
98
|
+
let journal = retainedJournal ?? inspected.journal;
|
|
99
|
+
rejectPodmanMigration(args, effects, journal?.record);
|
|
89
100
|
if (journal.phase === 'complete') {
|
|
90
101
|
const retained = effects.readJson(join(args.stateDir, 'installation.json'));
|
|
91
102
|
inspected.cliPlan.installerPath = await prepareCli(retained, effects);
|
package/lib/orchestrate.mjs
CHANGED
|
@@ -1316,13 +1316,14 @@ async function executeServerCommand(args, effects) {
|
|
|
1316
1316
|
const existing = record !== null;
|
|
1317
1317
|
if (existing) {
|
|
1318
1318
|
record = validateInstallation(record, args.stateDir);
|
|
1319
|
+
if (args.containerEngine && args.containerEngine !== (record.containerEngine ?? 'docker')) throw new Error('Conflicting container engine; explicit migration is required');
|
|
1319
1320
|
if (args.mode && args.mode !== record.mode) throw new Error('Conflicting runtime mode; retained installation was not changed');
|
|
1320
1321
|
if (args.operation !== 'update' && args.sources && (record.sourcePolicyHash
|
|
1321
1322
|
? effects.sourcePolicyHash(args.sources) !== record.sourcePolicyHash
|
|
1322
1323
|
: effects.readText(args.sources) !== effects.readText(record.sourcesPath))) throw new Error('Conflicting source selection; use explicit server update');
|
|
1323
1324
|
} else {
|
|
1324
1325
|
if (args.operation !== 'install' || !args.mode) throw new Error('First server install requires --mode');
|
|
1325
|
-
record = effects.newInstallation(args.stateDir, args.mode);
|
|
1326
|
+
record = effects.newInstallation(args.stateDir, args.mode, args);
|
|
1326
1327
|
for (const key of ['port', 'coworkPort', 'messengerPort']) if (args[key] !== undefined) record[key] = args[key];
|
|
1327
1328
|
}
|
|
1328
1329
|
if (effects.readJson(join(record.root, 'gateway-transition.json')) && args.operation !== 'gateway-enable' && args.operation !== 'status') throw new Error('Interrupted gateway migration; run server gateway-enable before other changes');
|
package/lib/plan.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateContainerEngine } from './container-engine.mjs';
|
|
1
2
|
import { gatewayAddress } from './gateway.mjs';
|
|
2
3
|
// ours-install v3 — daemon creation and boot-service installation.
|
|
3
4
|
//
|
|
@@ -357,6 +358,7 @@ export function installationPaths(record) {
|
|
|
357
358
|
}
|
|
358
359
|
|
|
359
360
|
export function validateInstallation(record, root) {
|
|
361
|
+
if (record) validateContainerEngine(record);
|
|
360
362
|
if (!record || ![1, 2].includes(record.schema) || !['docker', 'packages'].includes(record.mode)
|
|
361
363
|
|| record.root !== root || record.configPath !== installationPaths(record).config
|
|
362
364
|
|| record.sourcesPath !== join(root, 'sources.json') || record.workDir !== join(root, 'runtime')
|
|
@@ -386,7 +388,8 @@ export function validateInstallation(record, root) {
|
|
|
386
388
|
throw new Error('Invalid layout conversion record');
|
|
387
389
|
}
|
|
388
390
|
validateInstallation(source, root);
|
|
389
|
-
if (
|
|
391
|
+
if (JSON.stringify(source.containerBinding) !== JSON.stringify(record.containerBinding)) throw new Error('Conflicting conversion backend');
|
|
392
|
+
if (['mode', 'containerEngine', 'instanceId', 'project', 'sourcesPath', 'workDir'].some(key => source[key] !== record[key])
|
|
390
393
|
|| JSON.stringify(source.services) !== JSON.stringify(record.services)
|
|
391
394
|
|| conversion.runningServices.some(service => !source.services.includes(service))) {
|
|
392
395
|
throw new Error('Conflicting layout conversion source');
|
|
@@ -408,7 +411,7 @@ export function validateInstallation(record, root) {
|
|
|
408
411
|
throw new Error('Invalid server build transition');
|
|
409
412
|
}
|
|
410
413
|
validateInstallation(candidate, candidate.root);
|
|
411
|
-
for (const key of ['schema', 'mode', 'instanceId', 'services', 'gateway', 'port', 'coworkPort', 'messengerPort', 'messengerIdentity', 'uid', 'gid']) {
|
|
414
|
+
for (const key of ['schema', 'mode', 'containerEngine', 'containerBinding', 'instanceId', 'services', 'gateway', 'port', 'coworkPort', 'messengerPort', 'messengerIdentity', 'uid', 'gid']) {
|
|
412
415
|
if (JSON.stringify(candidate[key]) !== JSON.stringify(record[key])) throw new Error('Conflicting server build candidate');
|
|
413
416
|
}
|
|
414
417
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { runContainer } from './container-engine.mjs';
|
|
6
|
+
|
|
7
|
+
export const PROBE_IMAGE = 'docker.io/library/nginx:1.28-alpine@sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236';
|
|
8
|
+
/** Behavioral checks, in disposable resources, before touching installation storage. */
|
|
9
|
+
export async function qualifyPodman(effects, record) {
|
|
10
|
+
const root = mkdtempSync(join(tmpdir(), 'ours-podman-preflight-'));
|
|
11
|
+
const project = `ours-probe-${randomUUID()}`;
|
|
12
|
+
const file = join(root, 'compose.json'), overlay = join(root, 'reset.yaml');
|
|
13
|
+
const common = { image: PROBE_IMAGE, entrypoint: ['/bin/sh', '-ec'], read_only: true, cap_drop: ['ALL'], security_opt: ['no-new-privileges:true'] };
|
|
14
|
+
writeFileSync(file, JSON.stringify({ services: {
|
|
15
|
+
prepare: { ...common, user: '0:0', network_mode: 'none', cap_add: ['CHOWN', 'DAC_OVERRIDE'],
|
|
16
|
+
command: ['mkdir -p /storage/state/daemon /storage/state/sibling; chmod 700 /storage/state/daemon; chown 1000:1000 /storage/state/daemon'],
|
|
17
|
+
volumes: [{ type: 'volume', source: 'data', target: '/storage', volume: { nocopy: true } }] },
|
|
18
|
+
probe: { ...common, user: '1000:1000', command: ['test ! -e /data/sibling; test "$(stat -c %a /data)" = 700; nslookup -type=A probe.; echo ready > /data/probe; sleep 120'],
|
|
19
|
+
healthcheck: { test: ['CMD-SHELL', 'test -s /data/probe'], interval: '1s', timeout: '2s', retries: 10 },
|
|
20
|
+
volumes: [{ type: 'volume', source: 'data', target: '/data', volume: { nocopy: true, subpath: 'state/daemon' } }] },
|
|
21
|
+
}, volumes: { data: {} } }), { mode: 0o600 });
|
|
22
|
+
writeFileSync(overlay, 'services:\n probe:\n ports: !reset []\n', { mode: 0o600 });
|
|
23
|
+
const compose = args => runContainer(effects, record, ['compose', '-p', project, '-f', file, '-f', overlay, ...args], { timeout: 180000 });
|
|
24
|
+
try {
|
|
25
|
+
await compose(['config', '--format', 'json']);
|
|
26
|
+
await compose(['run', '--rm', '--no-deps', '-T', 'prepare']);
|
|
27
|
+
await compose(['up', '-d', '--no-build', '--wait', 'probe']);
|
|
28
|
+
const result = await compose(['ps', '--format', 'json']);
|
|
29
|
+
const rows = result.stdout.trim().startsWith('[') ? JSON.parse(result.stdout) : result.stdout.trim().split('\n').map(s => JSON.parse(s));
|
|
30
|
+
if (!rows.some(r => r.Service === 'probe' && r.State === 'running')) throw new Error('Compose JSON status is incompatible');
|
|
31
|
+
await compose(['exec', '-T', 'probe', '/bin/sh', '-ec', 'test -s /data/probe; test ! -e /data/state']);
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
let logs = '';
|
|
34
|
+
try { logs = (await compose(['logs', '--no-color', '--tail', '30'])).stdout; } catch {}
|
|
35
|
+
throw new Error(`Podman capability check failed (Compose !reset/wait/status, DNS, rootless UID, volume subpath): ${cause.message}\n${logs}`, { cause });
|
|
36
|
+
} finally {
|
|
37
|
+
try { await compose(['down', '--volumes', '--remove-orphans']); }
|
|
38
|
+
finally { rmSync(root, { recursive: true, force: true }); }
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/setup-options.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { join, resolve, isAbsolute, dirname } from 'node:path';
|
|
|
4
4
|
const scopes = ['all', 'server', 'client'];
|
|
5
5
|
const integrations = ['codex', 'claude-code', 'fleet'];
|
|
6
6
|
const valueFlags = new Map(Object.entries({
|
|
7
|
-
'--server-url': 'serverUrl', '--scope': 'scope', '--action': 'operation', '--mode': 'mode', '--state-dir': 'stateDir',
|
|
7
|
+
'--container-engine': 'containerEngine', '--server-url': 'serverUrl', '--scope': 'scope', '--action': 'operation', '--mode': 'mode', '--state-dir': 'stateDir',
|
|
8
8
|
'--identity-name': 'identityName', '--integrations': 'integrations', '--fleet-settings': 'fleetSettingsPath',
|
|
9
9
|
'--config': 'config', '--sources': 'sources', '--migrate-from': 'migrateFrom', '--port': 'port', '--cowork-port': 'coworkPort', '--messenger-port': 'messengerPort',
|
|
10
10
|
}));
|
|
@@ -41,6 +41,7 @@ export function validateSetupOptions(input, { interactive = input?.interactive =
|
|
|
41
41
|
if (missing.length) throw new Error(`Missing required setup options: ${missing.join(', ')}`);
|
|
42
42
|
if (options.mode === 'native') options.mode = 'packages';
|
|
43
43
|
if (server && !['packages', 'docker'].includes(options.mode)) throw new Error('Mode must be packages (or native) or docker');
|
|
44
|
+
if (options.containerEngine !== undefined && (!server || options.mode !== 'docker' || !['docker', 'podman'].includes(options.containerEngine))) throw new Error('--container-engine docker|podman requires server container mode');
|
|
44
45
|
if (options.serverUrl !== undefined) {
|
|
45
46
|
if (!server || options.mode !== 'docker' || options.operation !== 'install') throw new Error('--server-url requires Docker server installation');
|
|
46
47
|
options.serverUrl = serverBase(options.serverUrl);
|
package/lib/setup.mjs
CHANGED
|
@@ -54,6 +54,7 @@ export async function prepareSetupPlan(options, effects) {
|
|
|
54
54
|
const value = effects.readJson(join(options.stateDir, 'installation.json'));
|
|
55
55
|
if (value) {
|
|
56
56
|
plan.existing = validateInstallation(value, options.stateDir);
|
|
57
|
+
if (options.containerEngine && options.containerEngine !== (plan.existing.containerEngine ?? 'docker')) throw new InstallUsageError('Container engine conflicts with retained installation');
|
|
57
58
|
if (options.mode !== plan.existing.mode) throw new InstallUsageError('The selected mode conflicts with the retained installation; choose its existing mode or a separate empty directory');
|
|
58
59
|
for (const key of ['port', 'coworkPort', 'messengerPort']) {
|
|
59
60
|
if (options.explicitPorts?.includes(key) && options[key] !== plan.existing[key]) throw new InstallUsageError(`${key} conflicts with the retained installation`);
|
package/lib/target.mjs
CHANGED
|
@@ -464,7 +464,7 @@ export function parseNetworkArgs(argv) {
|
|
|
464
464
|
const operations = role === 'client' ? ['install'] : ['install', 'status', 'start', 'stop', 'restart', 'access-issue', 'access-replace', 'backup', 'restore', 'reset', 'update', 'rebuild', 'gateway-enable'];
|
|
465
465
|
if (!operations.includes(operation)) throw new InstallUsageError(`Unsupported ${role} operation: ${operation ?? '(missing)'}`);
|
|
466
466
|
const allowed = role === 'client' ? ['config'] : ['state-dir'];
|
|
467
|
-
if (role === 'server' && operation === 'install') allowed.push('mode', 'sources', 'migrate');
|
|
467
|
+
if (role === 'server' && operation === 'install') allowed.push('mode', 'sources', 'migrate', 'container-engine');
|
|
468
468
|
if (role === 'server' && ['install', 'gateway-enable'].includes(operation)) allowed.push('server-url');
|
|
469
469
|
if (operation === 'access-issue') allowed.push('output');
|
|
470
470
|
if (['access-replace', 'reset'].includes(operation)) allowed.push('confirm');
|
|
@@ -494,13 +494,14 @@ export function parseNetworkArgs(argv) {
|
|
|
494
494
|
} else {
|
|
495
495
|
const value = inline ?? argv[++i];
|
|
496
496
|
if (!value || value.startsWith('--')) throw new InstallUsageError(`--${name} requires a value`);
|
|
497
|
-
result[key] =
|
|
497
|
+
result[key] = ['mode', 'container-engine'].includes(name) ? value : name === 'server-url' ? serverBase(value) : resolve(value);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
const required = role === 'client' ? [] : ['stateDir'];
|
|
501
501
|
if (operation === 'access-issue') required.push('output');
|
|
502
502
|
if (['access-replace', 'reset'].includes(operation)) required.push('confirm');
|
|
503
503
|
for (const key of required) if (!result[key]) throw new InstallUsageError(`${operation} requires --${key.replace(/[A-Z]/g, c => '-' + c.toLowerCase())}`);
|
|
504
|
+
if (result.containerEngine !== undefined && (result.mode !== 'docker' || !['docker', 'podman'].includes(result.containerEngine))) throw new InstallUsageError('--container-engine docker|podman requires --mode docker');
|
|
504
505
|
if (result.mode && !['packages', 'docker'].includes(result.mode)) throw new InstallUsageError('--mode must be packages or docker');
|
|
505
506
|
return result;
|
|
506
507
|
}
|
package/lib/usage.mjs
CHANGED
|
@@ -22,6 +22,7 @@ export const USAGE = `ours-install — interactive setup or complete CLI presets
|
|
|
22
22
|
--scope all|server|client preset which parts to configure (default all)
|
|
23
23
|
--action install|update equivalent to the positional operation
|
|
24
24
|
--mode docker|native packages is also accepted for native mode
|
|
25
|
+
--container-engine docker|podman server container backend (default Docker); retained for maintenance
|
|
25
26
|
--state-dir PATH installation root; required for all/server
|
|
26
27
|
--identity-name NAME desired Human name for a fresh server; existing root is retained
|
|
27
28
|
--integrations LIST codex,claude-code,fleet; use none to skip clients explicitly
|