Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +95 -20
Dockerfile
CHANGED
|
@@ -1,29 +1,104 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
python3 \
|
| 5 |
-
make \
|
| 6 |
-
g++ \
|
| 7 |
-
git \
|
| 8 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
|
| 4 |
+
echo "🦞 Starting OpenClaw setup..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# 1. Tạo thư mục cần thiết
|
| 7 |
+
mkdir -p /root/.openclaw/agents/main/sessions
|
| 8 |
+
mkdir -p /root/.openclaw/workspace/skills
|
| 9 |
+
mkdir -p /root/.openclaw/reports
|
| 10 |
+
mkdir -p /root/.openclaw/logs
|
| 11 |
|
| 12 |
+
# 2. Khôi phục dữ liệu từ Dataset
|
| 13 |
+
python3 /app/sync.py restore || echo "No existing backup."
|
| 14 |
|
| 15 |
+
# 3. Nạp Skills
|
| 16 |
+
echo "📦 Đang nạp Skills..."
|
| 17 |
+
cd /root/.openclaw/workspace
|
| 18 |
+
npx clawhub@latest install reddit-readonly --force || true
|
| 19 |
+
# Đã tạm tắt skill nofx vì không đăng ký được key
|
| 20 |
+
# npx clawhub@latest install nofx-ai500-report --force || true
|
| 21 |
|
| 22 |
+
if [ -d /app/skills ]; then
|
| 23 |
+
cp -r /app/skills/* /root/.openclaw/workspace/skills/ 2>/dev/null || true
|
| 24 |
+
echo "✅ Custom skills loaded."
|
| 25 |
+
fi
|
| 26 |
+
cd /app
|
| 27 |
|
| 28 |
+
# 4. Cấu hình OpenClaw (Grok 4.1 Fast)
|
| 29 |
+
cat > /root/.openclaw/openclaw.json <<EOF
|
| 30 |
+
{
|
| 31 |
+
"models": {
|
| 32 |
+
"providers": {
|
| 33 |
+
"openai": {
|
| 34 |
+
"apiKey": "$GROK_API_KEY",
|
| 35 |
+
"baseUrl": "https://api.x.ai/v1",
|
| 36 |
+
"models": [
|
| 37 |
+
{
|
| 38 |
+
"id": "grok-4-1-fast-non-reasoning",
|
| 39 |
+
"name": "Grok 4.1 Fast (Non-Reasoning)",
|
| 40 |
+
"contextWindow": 2000000
|
| 41 |
+
}
|
| 42 |
+
]
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
},
|
| 46 |
+
"agents": {
|
| 47 |
+
"defaults": {
|
| 48 |
+
"model": {
|
| 49 |
+
"primary": "openai/grok-4-1-fast-non-reasoning"
|
| 50 |
+
},
|
| 51 |
+
"timeoutSeconds": 120
|
| 52 |
+
}
|
| 53 |
+
},
|
| 54 |
+
"gateway": {
|
| 55 |
+
"mode": "local",
|
| 56 |
+
"bind": "lan",
|
| 57 |
+
"port": 7860,
|
| 58 |
+
"trustedProxies": ["10.0.0.0/8"],
|
| 59 |
+
"auth": {
|
| 60 |
+
"mode": "token",
|
| 61 |
+
"token": "$OPENCLAW_GATEWAY_PASSWORD"
|
| 62 |
+
},
|
| 63 |
+
"controlUi": {
|
| 64 |
+
"enabled": true,
|
| 65 |
+
"allowedOrigins": ["*"],
|
| 66 |
+
"dangerouslyDisableDeviceAuth": true,
|
| 67 |
+
"allowInsecureAuth": true
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
EOF
|
| 72 |
|
| 73 |
+
# 5. Khởi động vòng lặp Backup (Mỗi 10 phút)
|
| 74 |
+
(while true; do sleep 600; python3 /app/sync.py backup >> /root/.openclaw/logs/backup.log 2>&1; done) &
|
| 75 |
+
echo "🔄 Backup loop started."
|
| 76 |
|
| 77 |
+
# ==========================================
|
| 78 |
+
# 6. MỞ KHÓA CRON JOBS (HỆ THỐNG TỰ ĐỘNG)
|
| 79 |
+
# ==========================================
|
| 80 |
+
echo "⏳ Setting up automated tasks..."
|
| 81 |
|
| 82 |
+
# Cài đặt cron service nếu chưa có (vì base image của Hugging Face có thể thiếu)
|
| 83 |
+
apt-get update && apt-get install -y cron || true
|
| 84 |
+
|
| 85 |
+
cat > /etc/cron.d/openclaw-tasks <<EOF
|
| 86 |
+
# Run Signal Detector every 5 minutes
|
| 87 |
+
*/5 * * * * root curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" -d '{"prompt": "Analyze BTCUSDT market and generate trading signals. Output JSON only."}' http://localhost:7860/v1/agents/main/run >> /root/.openclaw/logs/cron_signal.log 2>&1
|
| 88 |
+
|
| 89 |
+
# Run Technical Analysis every 2 hours
|
| 90 |
+
0 */2 * * * root curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" -d '{"prompt": "Perform detailed technical analysis for BTCUSDT and generate a markdown report."}' http://localhost:7860/v1/agents/main/run >> /root/.openclaw/logs/cron_ta.log 2>&1
|
| 91 |
+
|
| 92 |
+
# Run SEO Report every 6 hours
|
| 93 |
+
0 */6 * * * root curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" -d '{"prompt": "Generate a comprehensive SEO-optimized market report for the crypto community."}' http://localhost:7860/v1/agents/main/run >> /root/.openclaw/logs/cron_seo.log 2>&1
|
| 94 |
+
EOF
|
| 95 |
+
|
| 96 |
+
chmod 0644 /etc/cron.d/openclaw-tasks
|
| 97 |
+
crontab /etc/cron.d/openclaw-tasks
|
| 98 |
+
service cron start
|
| 99 |
+
echo "✅ Cron jobs activated!"
|
| 100 |
+
# ==========================================
|
| 101 |
+
|
| 102 |
+
export PORT=7860
|
| 103 |
+
echo "🚀 Starting gateway..."
|
| 104 |
+
exec openclaw gateway run
|