TraderAgent / Dockerfile
Sharker2308's picture
Update Dockerfile
30c96cf verified
Raw History Blame Contribute Delete
3.54 kB
#!/bin/bash
set -e
echo "🦞 Starting OpenClaw setup..."
# 1. Tạo thư mục cần thiết
mkdir -p /root/.openclaw/agents/main/sessions
mkdir -p /root/.openclaw/workspace/skills
mkdir -p /root/.openclaw/reports
mkdir -p /root/.openclaw/logs
# 2. Khôi phục dữ liệu từ Dataset
python3 /app/sync.py restore || echo "No existing backup."
# 3. Nạp Skills
echo "📦 Đang nạp Skills..."
cd /root/.openclaw/workspace
npx clawhub@latest install reddit-readonly --force || true
# Đã tạm tắt skill nofx vì không đăng ký được key
# npx clawhub@latest install nofx-ai500-report --force || true
if [ -d /app/skills ]; then
cp -r /app/skills/* /root/.openclaw/workspace/skills/ 2>/dev/null || true
echo "✅ Custom skills loaded."
fi
cd /app
# 4. Cấu hình OpenClaw (Grok 4.1 Fast)
cat > /root/.openclaw/openclaw.json <<EOF
{
"models": {
"providers": {
"openai": {
"apiKey": "$GROK_API_KEY",
"baseUrl": "https://api.x.ai/v1",
"models": [
{
"id": "grok-4-1-fast-non-reasoning",
"name": "Grok 4.1 Fast (Non-Reasoning)",
"contextWindow": 2000000
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "openai/grok-4-1-fast-non-reasoning"
},
"timeoutSeconds": 120
}
},
"gateway": {
"mode": "local",
"bind": "lan",
"port": 7860,
"trustedProxies": ["10.0.0.0/8"],
"auth": {
"mode": "token",
"token": "$OPENCLAW_GATEWAY_PASSWORD"
},
"controlUi": {
"enabled": true,
"allowedOrigins": ["*"],
"dangerouslyDisableDeviceAuth": true,
"allowInsecureAuth": true
}
}
}
EOF
# 5. Khởi động vòng lặp Backup (Mỗi 10 phút)
(while true; do sleep 600; python3 /app/sync.py backup >> /root/.openclaw/logs/backup.log 2>&1; done) &
echo "🔄 Backup loop started."
# ==========================================
# 6. MỞ KHÓA CRON JOBS (HỆ THỐNG TỰ ĐỘNG)
# ==========================================
echo "⏳ Setting up automated tasks..."
# Cài đặt cron service nếu chưa có (vì base image của Hugging Face có thể thiếu)
apt-get update && apt-get install -y cron || true
cat > /etc/cron.d/openclaw-tasks <<EOF
# Run Signal Detector every 5 minutes
*/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
# Run Technical Analysis every 2 hours
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
# Run SEO Report every 6 hours
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
EOF
chmod 0644 /etc/cron.d/openclaw-tasks
crontab /etc/cron.d/openclaw-tasks
service cron start
echo "✅ Cron jobs activated!"
# ==========================================
export PORT=7860
echo "🚀 Starting gateway..."
exec openclaw gateway run