feat: add Docker deployment, update install script, and project configs

- Add Dockerfile and docker-compose.yml for containerized deployment
- Rewrite install.sh for Docker-based setup (multi-distro support)
- Add Go module files (go.mod, go.sum) for WGRplane backend
- Add wgrplane.service systemd unit for Go backend
- Add CI verification scripts in scripts/
- Update README.md with Docker deployment docs
- Update .gitignore for binaries and .sisyphus/
This commit is contained in:
datadunia
2026-05-03 23:37:36 +07:00
parent 6d8899a078
commit 6e94e7338e
10 changed files with 852 additions and 1401 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail
echo "[CI] Verifying Gorilla dependencies and WebSocket endpoint (WS) in Go-enabled environment"
cd app
echo ">> Checking Go toolchain..."
if ! command -v go >/dev/null 2>&1; then
echo "Go is not installed in this environment. Exiting.";
exit 0
fi
echo ">> Fetching dependencies..."
go get -u github.com/gorilla/mux
go get -u github.com/gorilla/websocket
echo ">> Tidying modules..."
go mod tidy
echo ">> Building project..."
go build ./...
echo ">> Running server in background..."
go run main.go &
PID=$!
echo "[CI] Server PID: $PID"
sleep 2
echo ">> Testing WebSocket endpoint (ws://localhost:8080/ws/stats) using simple client..."
if command -v websocat >/dev/null 2>&1; then
websocat -b ws://localhost:8080/ws/stats >/tmp/ws_test.txt &
WS_PID=$!
sleep 6
kill $WS_PID 2>/dev/null || true
echo "Captured output:"; head -n 5 /tmp/ws_test.txt || true
else
echo "websocat not installed. Install to run WS test or use another client."
fi
echo ">> Cleaning up server process..."
kill $PID 2>/dev/null || true
wait $PID 2>/dev/null || true
echo "[CI] Verification script completed."
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
###########################################
# End-to-end verification for /api/peers/*
# Requires: curl, jq, xxd, file (coreutils)
###########################################
API_KEY="${WG_API_KEY:-test-api-key}"
BASE_URL="${WG_BASE_URL:-http://127.0.0.1:8080}"
echo "[VERIF-EE] Starting end-to-end verification against ${BASE_URL}"
echo "[STEP] Seed server"
SERVER_PAYLOAD='{"name":"test-server","mode":"forward","PublicKey":"SERVER_PUBLIC_KEY_BASE64","Endpoint":"server.example:51820"}'
SERVER_ID=$(curl -s -H "wg-rplane-datadunia: ${API_KEY}" -H "Content-Type: application/json" -d "$SERVER_PAYLOAD" "$BASE_URL/api/servers" | jq -r '.id')
echo "[INFO] SERVER_ID=${SERVER_ID}"
echo "[STEP] Seed peer"
PEER_PAYLOAD='{"PublicKey":"PEER_PUBLIC_KEY_BASE64","IP":"10.0.0.2","AllowAccess":"[]","AllowInternet":false}'
PEER_ID=$(curl -s -H "wg-rplane-datadunia: ${API_KEY}" -H "Content-Type: application/json" -d "$PEER_PAYLOAD" "$BASE_URL/api/servers/${SERVER_ID}/peers" | jq -r '.id')
echo "[INFO] PEER_ID=${PEER_ID}"
echo "[STEP] Fetch config"
CONFIG_JSON=$(curl -s -w "%{http_code}" -H "wg-rplane-datadunia: ${API_KEY}" "$BASE_URL/api/peers/${PEER_ID}/config")
STATUS=$(tail -c 3 <<< "$CONFIG_JSON");
CONFIG_BODY=$(echo "$CONFIG_JSON" | sed '$d')
if [ "$STATUS" != "200" ]; then
echo "[ERROR] Config endpoint returned status code ${STATUS}"; exit 1
fi
echo "$CONFIG_BODY" > /tmp/peer_config.conf
echo "[STEP] Validate config content"
grep -q "^\\[Interface\\]" /tmp/peer_config.conf || { echo "Config missing [Interface]"; exit 1; }
grep -q "^\\[Peer\\]" /tmp/peer_config.conf || { echo "Config missing [Peer]"; exit 1; }
echo "[STEP] Fetch QR code"
curl -s -o /tmp/peer.png -D /tmp/peer_headers.txt -H "wg-rplane-datadunia: ${API_KEY}" "$BASE_URL/api/peers/${PEER_ID}/qrcode" || { echo "Failed to fetch QR code"; exit 1; }
echo "[INFO] QR code saved to /tmp/peer.png"
echo "[STEP] Validate PNG file"
if file /tmp/peer.png | grep -qi png; then
echo "[OK] PNG detected"
else
echo "[ERROR] Not a PNG file"
exit 1
fi
echo "[VERIF-EE] End-to-end verification completed successfully."