-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·124 lines (99 loc) · 4.79 KB
/
deploy.sh
File metadata and controls
executable file
·124 lines (99 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
set -euo pipefail
# CameraClaw Deploy Script
# Installs Node.js dependencies, verifies Docker, and prepares the OpenClaw image.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "╔══════════════════════════════════════════╗"
echo "║ CameraClaw — Deploy ║"
echo "╚══════════════════════════════════════════╝"
echo ""
# ── Node.js Detection ─────────────────────────────────────────────────────────
NODE_BIN=""
for candidate in node node18 node20 node22; do
if command -v "$candidate" &>/dev/null; then
version=$("$candidate" --version 2>/dev/null | sed 's/v//')
major=$(echo "$version" | cut -d. -f1)
if [ "$major" -ge 18 ] 2>/dev/null; then
NODE_BIN="$candidate"
echo "✅ Node.js: $candidate ($version)"
break
fi
fi
done
if [ -z "$NODE_BIN" ]; then
echo "❌ Node.js >= 18 not found"
echo " Install: https://nodejs.org/ or 'brew install node'"
exit 1
fi
# ── npm Install ────────────────────────────────────────────────────────────────
echo ""
echo "📦 Installing dependencies..."
npm install --omit=dev 2>&1
echo "✅ Dependencies installed"
# ── Docker Detection ──────────────────────────────────────────────────────────
echo ""
if ! command -v docker &>/dev/null; then
echo "❌ Docker: not installed"
echo " macOS: brew install --cask docker"
echo " Linux: sudo apt-get install docker.io"
exit 1
fi
if ! docker info &>/dev/null 2>&1; then
echo "❌ Docker: daemon not running"
echo " Start Docker Desktop or: sudo systemctl start docker"
exit 1
fi
echo "✅ Docker: available and running"
if ! docker compose version &>/dev/null 2>&1; then
echo "❌ Docker Compose: not available"
exit 1
fi
echo "✅ Docker Compose: available"
# ── Prepare OpenClaw Config Directory ─────────────────────────────────────────
echo ""
OPENCLAW_DIR="${HOME}/.openclaw"
if [ ! -d "$OPENCLAW_DIR" ]; then
echo "📁 Creating OpenClaw config directory: $OPENCLAW_DIR"
mkdir -p "$OPENCLAW_DIR"
mkdir -p "$OPENCLAW_DIR/workspace"
fi
echo "✅ Config dir: $OPENCLAW_DIR"
# ── Build/Pull OpenClaw Image ─────────────────────────────────────────────────
echo ""
echo "🐳 Preparing OpenClaw Docker image..."
# Check if image already exists
if docker image inspect openclaw:2026.3.12 &>/dev/null 2>&1; then
echo "✅ OpenClaw image: openclaw:2026.3.12 (already built)"
else
echo " Image openclaw:local not found — building locally..."
echo " Building openclaw:local (npm install + desktop packages)..."
# Build using the Dockerfile at the skill root
# Build context is the skill root so COPY scripts/setup-desktop.sh works
docker build -t openclaw:2026.3.12 "$SCRIPT_DIR"
# Also tag as openclaw:local for backward compatibility
docker tag openclaw:2026.3.12 openclaw:local
if docker image inspect openclaw:2026.3.12 &>/dev/null 2>&1; then
echo "✅ OpenClaw image: openclaw:2026.3.12 (built locally)"
else
echo "❌ Failed to build OpenClaw image"
exit 1
fi
fi
# ── Verify docker-compose.yml ──────────────────────────────────────────────────
echo ""
if [ -f "$SCRIPT_DIR/docker-compose.yml" ]; then
docker compose -f "$SCRIPT_DIR/docker-compose.yml" config --quiet 2>/dev/null && \
echo "✅ docker-compose.yml: valid" || \
echo "⚠️ docker-compose.yml: validation warning (may still work)"
else
echo "❌ docker-compose.yml: missing"
exit 1
fi
# ── Summary ────────────────────────────────────────────────────────────────────
echo ""
echo "────────────────────────────────────────────"
echo "✅ CameraClaw ready (Docker mode)"
echo " Run: $NODE_BIN scripts/monitor.js"
echo ""
echo "Deploy complete."