feat: add various infrastructure check and automation scripts
This commit is contained in:
@@ -65,8 +65,10 @@ def cmd_plan():
|
||||
print(f" Save Dir: {server.get('saveDirectory')}")
|
||||
print(f" Backup: {spec.get('backup', {}).get('schedule')} (Retention: {spec.get('backup', {}).get('retentionDays')}d)")
|
||||
|
||||
def cmd_generate_compose(output_path="docker-compose.yml"):
|
||||
def cmd_generate_compose(output_path=None):
|
||||
"""Generates standard docker-compose.yml from all declared seeds."""
|
||||
if output_path is None:
|
||||
output_path = Path(__file__).resolve().parent.parent / "docker-compose.yml"
|
||||
seeds = load_seeds()
|
||||
services = {}
|
||||
|
||||
@@ -85,31 +87,39 @@ def cmd_generate_compose(output_path="docker-compose.yml"):
|
||||
save_dir = server.get("saveDirectory")
|
||||
data_dir = f"/opt/game-servers/{name}/data"
|
||||
|
||||
mem_limit = str(res.get("memoryLimit", "8g")).lower().replace("gi", "g")
|
||||
mem_res = str(res.get("memoryReservation", "4g")).lower().replace("gi", "g")
|
||||
cpu_limit = str(res.get("cpuLimit", "4"))
|
||||
|
||||
volumes = runtime.get("volumes")
|
||||
if not volumes:
|
||||
volumes = [
|
||||
f"{save_dir}:{save_dir}",
|
||||
f"{data_dir}:/serverdata"
|
||||
]
|
||||
|
||||
services[name] = {
|
||||
"image": runtime.get("image"),
|
||||
"container_name": f"gameseed-{name}",
|
||||
"restart": runtime.get("restartPolicy", "unless-stopped"),
|
||||
"env_file": [".env"],
|
||||
"environment": runtime.get("environment", {}),
|
||||
"ports": ports,
|
||||
"volumes": [
|
||||
f"{save_dir}:{save_dir}",
|
||||
f"{data_dir}:/serverdata"
|
||||
],
|
||||
"volumes": volumes,
|
||||
"deploy": {
|
||||
"resources": {
|
||||
"limits": {
|
||||
"memory": res.get("memoryLimit", "8Gi"),
|
||||
"cpus": res.get("cpuLimit", "4")
|
||||
"memory": mem_limit,
|
||||
"cpus": cpu_limit
|
||||
},
|
||||
"reservations": {
|
||||
"memory": res.get("memoryReservation", "4Gi")
|
||||
"memory": mem_res
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compose = {
|
||||
"version": "3.8",
|
||||
"services": services
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user