From f9c27719842c1ec7cfd2d25429a8d5776ca4ae60 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 17:10:23 +0000 Subject: [PATCH] feat: docker-compose.yml per node, minimal nginx config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /opt/fw/{name}/docker-compose.yml — declarative, editable - /opt/fw/{name}/nginx/default.conf — user-editable - docker compose up -d for deployment - Remove rate limits and header manipulation (app handles it) --- sources/python/main.py | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index 0a1dbae..e799efb 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -62,21 +62,15 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label if not os.path.exists(nginx_conf): with open(nginx_conf, "w") as f: f.write(f"""server {{ - listen {port}; + listen 80; server_name _; - set_real_ip_from 10.0.0.0/8; - real_ip_header X-Real-IP; - real_ip_recursive on; location /wallarm-status {{ wallarm_status on; allow 127.0.0.0/8; deny all; }} - location /health {{ - access_log off; - return 200 "healthy\n"; - }} + location / {{ proxy_pass http://{upstream_ip}:{upstream_port}; proxy_set_header Host $host; @@ -87,24 +81,31 @@ def deploy_container(name, token, cloud, port, upstream_ip, upstream_port, label }} """) - # Run container - monitoring_port = int(port) + 10 - print(f"[{name}] Starting container on port {port}...") - cmd = f"""docker run -d \ - --name {container} \ - --restart unless-stopped \ - -p {port}:{port} \ - -v {host_dir}/nginx:/etc/nginx/http.d:ro -v {host_dir}/etc:/opt/wallarm/etc \ - -p {monitoring_port}:{monitoring_port} \ - -e WALLARM_API_TOKEN={token} \ - -e WALLARM_API_HOST={api_host} \ - -e WALLARM_MODE={mode} \ - -e NGINX_PORT={port}""" - if upstream_ip: - cmd += f" -e WALLARM_UPSTREAM=http://{upstream_ip}:{upstream_port}" - cmd += f" {WALLARM_IMAGE}" + # Generate docker-compose.yml + start + compose_path = f"{host_dir}/docker-compose.yml" + 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/default.conf:/etc/nginx/http.d/default.conf:ro + - ./etc:/opt/wallarm/etc + logging: + driver: json-file + options: + max-size: 10m +""") - r = run(cmd, timeout=30) + print(f"[{name}] Starting via compose...") + r = run(f"cd {host_dir} && docker compose up -d", timeout=30) if r.returncode != 0: print(f"❌ {name}: {r.stderr}") return False