services: server: build: context: . dockerfile: Dockerfile.server container_name: zm-server hostname: server privileged: true ports: - "7100:10001" command: - sh - -c - | mkdir -p /tmp/data && zeromesh -config /etc/zeromesh/config.yaml healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:10001/api/health"] interval: 3s retries: 30 start_period: 5s networks: zmt: ipv4_address: 172.30.0.10 init: image: alpine:3.19 container_name: zm-init hostname: init depends_on: server: condition: service_healthy command: - sh - -c - | apk add --no-cache curl jq echo '=== Create admin (try init then login) ===' ADMIN=$$(curl -s -X POST http://server:10001/api/v1/auth/init \ -H 'Content-Type: application/json' \ -d '{"username":"admin","password":"admin123456"}') TOKEN=$$(echo "$$ADMIN" | jq -r '.token // empty') if [ -z "$$TOKEN" ]; then echo 'Admin already exists, logging in...' LOGIN=$$(curl -s -X POST http://server:10001/api/v1/auth/login \ -H 'Content-Type: application/json' \ -d '{"username":"admin","password":"admin123456"}') TOKEN=$$(echo "$$LOGIN" | jq -r '.token // empty') fi if [ -z "$$TOKEN" ]; then echo "Failed to get admin token"; exit 1; fi echo 'Admin token acquired' sleep 1 echo '=== Create network ===' curl -s -X POST http://server:10001/api/v1/network/create \ -H "Authorization: Bearer $$TOKEN" \ -H 'Content-Type: application/json' \ -d '{"name":"testnet","ip_range":"10.7.0.0/24"}' echo '' echo '=== init done ===' networks: - zmt client1: build: context: . dockerfile: Dockerfile.client container_name: zm-client1 hostname: client1 privileged: true ports: - "7201:7001/udp" depends_on: init: condition: service_completed_successfully command: - sh - -c - | zmclient -server http://server:10001 -name client1 -udp 7001 -tap ztmesh0 -identity /tmp/c1.id networks: zmt: ipv4_address: 172.30.0.11 client2: build: context: . dockerfile: Dockerfile.client container_name: zm-client2 hostname: client2 privileged: true ports: - "7202:7002/udp" depends_on: init: condition: service_completed_successfully command: - sh - -c - | zmclient -server http://server:10001 -name client2 -udp 7002 -tap ztmesh1 -identity /tmp/c2.id networks: zmt: ipv4_address: 172.30.0.12 client3: build: context: . dockerfile: Dockerfile.client container_name: zm-client3 hostname: client3 privileged: true ports: - "7203:7003/udp" depends_on: init: condition: service_completed_successfully command: - sh - -c - | zmclient -server http://server:10001 -name client3 -udp 7003 -tap ztmesh2 -identity /tmp/c3.id networks: zmt: ipv4_address: 172.30.0.13 tester: image: alpine:3.19 container_name: zm-tester hostname: tester privileged: true depends_on: init: condition: service_completed_successfully command: - sh - -c - | apk add --no-cache iputils iproute2 curl bash echo '=== Waiting for clients (60s) ===' sleep 60 echo '=== Login ===' LOGIN=$$(curl -s -X POST http://server:10001/api/v1/auth/login \ -H 'Content-Type: application/json' \ -d '{"username":"admin","password":"admin123456"}') TOKEN=$$(echo "$$LOGIN" | sed 's/.*"token":"//' | sed 's/".*//') echo '=== Networks ===' curl -s http://server:10001/api/v1/network/list \ -H "Authorization: Bearer $$TOKEN" | head -c 300 echo '' echo '=== Members (network/1) ===' curl -s http://server:10001/api/v1/network/1/members \ -H "Authorization: Bearer $$TOKEN" | sed 's/,/\n/g' | grep -E 'node_id|ip_address|authorized' echo '' echo '=== Online Nodes ===' NODES=$$(curl -s http://server:10001/api/v1/node/online \ -H "Authorization: Bearer $$TOKEN") echo "$$NODES" | sed 's/,/\n/g' | grep -E 'node_id|ip_address|port|name' echo '' echo '=== Try pinging virtual IPs ===' networks: - zmt networks: zmt: driver: bridge ipam: config: - subnet: 172.30.0.0/24