feat: add JD01 YAML-first deployment support

This commit is contained in:
Codex
2026-06-29 08:13:34 +00:00
parent fe917bec4a
commit 076c4b643d
49 changed files with 10909 additions and 5223 deletions
+29 -1
View File
@@ -45,6 +45,16 @@ function safeProviderSlug(providerId: string): string {
return providerId.replace(/[^a-zA-Z0-9_.-]/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "provider";
}
function defaultHostSshUser(hostProjectRoot: string): string {
const homeMatch = hostProjectRoot.match(/^\/home\/([^/]+)/u);
if (homeMatch?.[1]) return homeMatch[1];
return "root";
}
function defaultHostRemoteCwd(user: string): string {
return user === "root" ? "/root" : `/home/${user}`;
}
function defaultMasterServer(config: UniDeskConfig): string {
return `http://${config.network.publicHost}/`;
}
@@ -88,11 +98,27 @@ function parseAttachOptions(config: UniDeskConfig, args: string[]): ProviderAtta
}
function envContent(options: ProviderAttachOptions): string {
const slug = safeProviderSlug(options.providerId);
const hostSshUser = defaultHostSshUser(repoRoot);
const lines = [
"# Generated by: bun scripts/cli.ts provider attach",
"# Required attach inputs are intentionally limited to master server and provider id.",
"# Required attach inputs are intentionally limited to master server, provider id, and optional provider token.",
`UNIDESK_MASTER_SERVER=${options.masterServer}`,
`PROVIDER_ID=${options.providerId}`,
`PROVIDER_NAME=${options.providerId}`,
`PROVIDER_UPGRADE_HOST_PROJECT_ROOT=${repoRoot}`,
"PROVIDER_UPGRADE_WORKSPACE_PATH=/workspace",
`PROVIDER_UPGRADE_COMPOSE_FILE=provider-${options.providerId}.yml`,
`PROVIDER_UPGRADE_ENV_FILE=.state/provider-${options.providerId}.env`,
`PROVIDER_UPGRADE_COMPOSE_PROJECT=unidesk-${slug}`,
"PROVIDER_UPGRADE_SERVICE=provider-gateway",
`PROVIDER_UPGRADE_RUNNER_IMAGE=unidesk_provider-gateway:${slug}`,
"HOST_SSH_HOST=host.docker.internal",
"HOST_SSH_PORT=22",
`HOST_SSH_USER=${hostSshUser}`,
"HOST_SSH_KEY=/run/host-ssh/id_ed25519",
`HOST_REMOTE_CWD=${defaultHostRemoteCwd(hostSshUser)}`,
"HOST_LOGIN_SHELL=/bin/bash",
];
if (options.token !== null) lines.push(`PROVIDER_TOKEN=${options.token}`);
return `${lines.join("\n")}\n`;
@@ -109,6 +135,8 @@ function composeContent(options: ProviderAttachOptions): string {
" build:",
" context: .",
" dockerfile: src/components/provider-gateway/Dockerfile",
" args:",
' ALPINE_REPOSITORY: "${PROVIDER_GATEWAY_ALPINE_REPOSITORY:-}"',
` container_name: unidesk-provider-gateway-${slug}`,
" restart: always",
' pid: "host"',