refacotr: 重构部署实现,不每次都重新构建镜像,只在第一次构建,后面只将编译产物放入挂载目录重启容器

This commit is contained in:
ah--desktop
2026-07-12 17:13:45 +08:00
parent 7a2498cef2
commit b9a75af67c
13 changed files with 523 additions and 130 deletions
+20
View File
@@ -7,6 +7,7 @@ import type { DeployConfig, Environment, Service, ServiceEnvConfig, ServerConfig
const __dirname = dirname(fileURLToPath(import.meta.url));
const CONFIG_PATH = process.env.ECOM_DEPLOY_CONFIG || join(__dirname, '..', 'config.json');
const ARTIFACTS_ROOT = join(__dirname, '..', 'artifacts');
const SSH_KEY_PATH = join(homedir(), '.ssh', 'ecom-deploy');
export function getSshKeyPath(): string {
@@ -90,6 +91,25 @@ export function getConfigPath(): string {
return CONFIG_PATH;
}
/** 本地编译产物根目录 ecom-deploy/artifacts */
export function getArtifactsRoot(): string {
return ARTIFACTS_ROOT;
}
export function getArtifactDir(service: Service): string {
return join(ARTIFACTS_ROOT, service);
}
/** 远程服务目录(含 Dockerfile、data 挂载点) */
export function getRemoteServiceDir(cfg: ServiceEnvConfig, service: Service): string {
return `${cfg.server.deployPath}/${service}`;
}
/** 远程挂载目录,容器内映射为 /data */
export function getRemoteDataDir(cfg: ServiceEnvConfig, service: Service): string {
return `${getRemoteServiceDir(cfg, service)}/data`;
}
/** 与 application-{profile}.yml 中 server.port 保持一致 */
export function resolveBackendPort(env: Environment): number {
switch (env) {