更新: 359 个文件 - 2026-03-16 23:30:01
这个提交包含在:
32
scripts/lab/compose.py
普通文件
32
scripts/lab/compose.py
普通文件
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
from lab.utils import write_yaml
|
||||
|
||||
|
||||
def compose_payload(profile: Dict[str, Any]) -> Dict[str, Any]:
|
||||
services = {}
|
||||
for service_name, service in profile.get("services", {}).items():
|
||||
payload = {
|
||||
"image": service["image"],
|
||||
}
|
||||
if service.get("ports"):
|
||||
payload["ports"] = service["ports"]
|
||||
if service.get("environment"):
|
||||
payload["environment"] = service["environment"]
|
||||
if service.get("depends_on"):
|
||||
payload["depends_on"] = service["depends_on"]
|
||||
services[service_name] = payload
|
||||
return {
|
||||
"services": services,
|
||||
"networks": {"labnet": {"driver": "bridge"}},
|
||||
}
|
||||
|
||||
|
||||
def generate_compose(profile: Dict[str, Any], run_dir: Path) -> Tuple[Path, Dict[str, Any]]:
|
||||
payload = compose_payload(profile)
|
||||
compose_path = run_dir / "compose" / "compose.yaml"
|
||||
write_yaml(compose_path, payload)
|
||||
return compose_path, payload
|
||||
在新工单中引用
屏蔽一个用户