fix: start.sh per node — declarative config + startup, no compose needed

This commit is contained in:
admin 2026-08-03 17:28:57 +00:00
parent a2650e5c36
commit 202f0e2dc8

View file

@ -57,27 +57,25 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
host_dir = f"{BASE}/{name}"
os.makedirs(host_dir, exist_ok=True)
# Generate compose.yaml
compose_path = f"{host_dir}/compose.yaml"
with open(compose_path, "w") as f:
f.write(f"""services:
wallarm:
image: {WALLARM_IMAGE}
container_name: {container}
restart: always
ports:
- "{port}:80"
environment:
- WALLARM_API_TOKEN={token}
- WALLARM_API_HOST={api_host}
- WALLARM_MODE={mode}
volumes:
- ./nginx.conf:/etc/nginx/http.d/default.conf:ro
logging:
driver: json-file
options:
max-size: 10m
# Generate start.sh (declarative config + startup in one file)
start_path = f"{host_dir}/start.sh"
with open(start_path, "w") as f:
f.write(f"""#!/bin/bash
# Wallarm node: {name}
docker rm -f {container} 2>/dev/null || true
docker run -d \\
--name {container} \\
--restart always \\
-p {port}:80 \\
-e WALLARM_API_TOKEN='{token}' \\
-e WALLARM_API_HOST={api_host} \\
-e WALLARM_MODE={mode} \\
-v {host_dir}/nginx.conf:/etc/nginx/http.d/default.conf:ro \\
{WALLARM_IMAGE}
sleep 3
docker ps --filter name={container} --format '{{{{.Status}}}}'
""")
os.chmod(start_path, 0o755)
# Write nginx.conf with production defaults
nginx_conf = f"{host_dir}/nginx.conf"
@ -106,8 +104,8 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label
}}
""")
print(f"[{name}] Starting via compose...")
r = run(f"cd {host_dir} && docker compose up -d", timeout=30)
print(f"[{name}] Starting...")
r = run(f"bash {start_path}", timeout=30)
if r.returncode != 0:
print(f"{name}: {r.stderr}")
return False