fix(deployment): harden backend core recovery
This commit is contained in:
@@ -27,6 +27,7 @@ export function isRebuildableService(value: string | undefined): value is Rebuil
|
||||
}
|
||||
|
||||
export function resolveComposeCommand(config: UniDeskConfig, envFile: string): string[] {
|
||||
assertCanonicalServerRoot(config);
|
||||
const composeFile = rootPath(config.docker.composeFile);
|
||||
if (commandOk(["docker", "compose", "version"], repoRoot)) {
|
||||
return ["docker", "compose", "--env-file", envFile, "-f", composeFile, "-p", config.docker.projectName];
|
||||
@@ -52,7 +53,21 @@ function envValue(value: string): string {
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function assertCanonicalServerRoot(config: UniDeskConfig): void {
|
||||
const canonicalRoot = resolve(config.providerGateway.upgrade.hostProjectRoot);
|
||||
const currentRoot = resolve(repoRoot);
|
||||
if (currentRoot !== canonicalRoot) {
|
||||
throw new Error([
|
||||
"Main-server Docker Compose commands must run from the canonical UniDesk root.",
|
||||
`canonicalRoot=${canonicalRoot}`,
|
||||
`currentRoot=${currentRoot}`,
|
||||
`Run from the canonical root: cd ${canonicalRoot} && bun scripts/cli.ts server <start|status|logs|rebuild|stop>`,
|
||||
].join(" "));
|
||||
}
|
||||
}
|
||||
|
||||
export function writeComposeEnv(config: UniDeskConfig, freshLogPrefix: boolean): ComposeRuntimeEnv {
|
||||
assertCanonicalServerRoot(config);
|
||||
const stateDir = rootPath(config.paths.stateDir);
|
||||
mkdirSync(stateDir, { recursive: true });
|
||||
const envFile = join(stateDir, "docker-compose.env");
|
||||
|
||||
Reference in New Issue
Block a user