feat(deployer): add deb package distribution and install via scp/apt

This commit is contained in:
2026-08-24 11:25:43 +08:00
parent e4d4319919
commit e7a139e2cb
5 changed files with 273 additions and 25 deletions
+2 -20
View File
@@ -21,7 +21,7 @@ import os
import subprocess
import sys
from lib import project_root, service_info, ssh_cmd
from lib import project_root, run_remote, service_info
REMOTE_COMMANDS = {
"up": "docker compose up -d",
@@ -33,23 +33,6 @@ REMOTE_COMMANDS = {
}
def run_ssh(info: dict, compose_command: str) -> int:
remote_dir = info["remote_dir"]
remote_shell = f"cd {remote_dir} && {compose_command}"
cmd = ssh_cmd(info, remote_shell)
endpoint = info["node"]
if info.get("port") is not None:
endpoint = f"{endpoint}:{info['port']}"
print(f"远程执行: {endpoint}:{remote_dir}")
print(f"$ {compose_command}")
print("-" * 60)
try:
return subprocess.run(cmd, check=False).returncode
except FileNotFoundError:
print("错误: ssh 命令未找到")
return 1
def run_for_service(service_dir: str, action: str) -> int:
info = service_info(service_dir)
compose_command = REMOTE_COMMANDS[action]
@@ -57,8 +40,7 @@ def run_for_service(service_dir: str, action: str) -> int:
if info.get("port") is not None:
endpoint = f"{endpoint}:{info['port']}"
print(f"服务: {service_dir} -> {endpoint}:{info['remote_dir']}")
return run_ssh(info, compose_command)
return run_remote(info, compose_command, remote_cwd=info["remote_dir"])
def main() -> int: