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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:22-slim
|
| 2 |
+
|
| 3 |
+
# 1. Install system dependencies, python, and browser requirements
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
git \
|
| 6 |
+
curl \
|
| 7 |
+
zip \
|
| 8 |
+
unzip \
|
| 9 |
+
tar \
|
| 10 |
+
xz-utils \
|
| 11 |
+
bzip2 \
|
| 12 |
+
python3 \
|
| 13 |
+
python3-pip \
|
| 14 |
+
libglib2.0-0 \
|
| 15 |
+
libnss3 \
|
| 16 |
+
libnspr4 \
|
| 17 |
+
libatk1.0-0 \
|
| 18 |
+
libatk-bridge2.0-0 \
|
| 19 |
+
libcups2 \
|
| 20 |
+
libdrm2 \
|
| 21 |
+
libxkbcommon0 \
|
| 22 |
+
libxcomposite1 \
|
| 23 |
+
libxdamage1 \
|
| 24 |
+
libxrandr2 \
|
| 25 |
+
libgbm1 \
|
| 26 |
+
libgtk-3-0 \
|
| 27 |
+
libasound2 \
|
| 28 |
+
libpango-1.0-0 \
|
| 29 |
+
libcairo2 \
|
| 30 |
+
rsync \
|
| 31 |
+
&& npx playwright install-deps chromium \
|
| 32 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
+
|
| 34 |
+
# 2. Install OpenClaw and browser tools
|
| 35 |
+
RUN npm install -g openclaw@latest agent-browser pdfnano
|
| 36 |
+
|
| 37 |
+
# 3. Install Hugging Face Hub (Python)
|
| 38 |
+
RUN pip3 install --no-cache-dir --break-system-packages huggingface_hub
|
| 39 |
+
|
| 40 |
+
# 4. Install Chromium and link it for OpenClaw
|
| 41 |
+
RUN agent-browser install chromium && \
|
| 42 |
+
ln -s $(find /root/.cache/ms-playwright -name chrome -type f | grep -v "shell" | head -n 1) /usr/bin/google-chrome
|
| 43 |
+
|
| 44 |
+
# 5. Create directory structure
|
| 45 |
+
RUN mkdir -p /root/.openclaw/agents/main/agent \
|
| 46 |
+
/root/.openclaw/agents/main/sessions \
|
| 47 |
+
/root/.openclaw/credentials \
|
| 48 |
+
/root/.openclaw/workspace
|
| 49 |
+
|
| 50 |
+
ENV PORT=7860
|
| 51 |
+
ENV OPENCLAW_GATEWAY_MODE=local
|
| 52 |
+
EXPOSE 7860
|
| 53 |
+
|
| 54 |
+
# 6. Startup script
|
| 55 |
+
RUN cat > /usr/local/bin/start-openclaw << 'EOF'
|
| 56 |
+
#!/bin/bash
|
| 57 |
+
set -e
|
| 58 |
+
|
| 59 |
+
OPENCLAW_DIR="/root/.openclaw"
|
| 60 |
+
HF_TMP="/tmp/hf-restore"
|
| 61 |
+
|
| 62 |
+
# DNS
|
| 63 |
+
echo "nameserver 1.1.1.1" > /etc/resolv.conf 2>/dev/null || true
|
| 64 |
+
echo "nameserver 8.8.8.8" >> /etc/resolv.conf 2>/dev/null || true
|
| 65 |
+
|
| 66 |
+
# --- RESTORE FROM HF DATASET ---
|
| 67 |
+
if [[ -n "$HF_DATASET_TOKEN" && -n "$HF_DATASET" ]]; then
|
| 68 |
+
echo "[HF] Restoring dataset: $HF_DATASET"
|
| 69 |
+
|
| 70 |
+
rm -rf "$HF_TMP"
|
| 71 |
+
mkdir -p "$HF_TMP"
|
| 72 |
+
|
| 73 |
+
python3 << 'EOP'
|
| 74 |
+
import os
|
| 75 |
+
from huggingface_hub import snapshot_download
|
| 76 |
+
|
| 77 |
+
snapshot_download(
|
| 78 |
+
repo_id=os.environ["HF_DATASET"],
|
| 79 |
+
repo_type="dataset",
|
| 80 |
+
local_dir="/tmp/hf-restore",
|
| 81 |
+
allow_patterns=["data/**"],
|
| 82 |
+
token=os.environ["HF_DATASET_TOKEN"]
|
| 83 |
+
)
|
| 84 |
+
print("[HF] Download complete")
|
| 85 |
+
EOP
|
| 86 |
+
|
| 87 |
+
# CRITICAL FIX: merge data/* into live OpenClaw dir
|
| 88 |
+
if [ -d "$HF_TMP/data" ]; then
|
| 89 |
+
rsync -a "$HF_TMP/data/" "$OPENCLAW_DIR/"
|
| 90 |
+
echo "[HF] Data merged into OpenClaw workspace"
|
| 91 |
+
fi
|
| 92 |
+
fi
|
| 93 |
+
|
| 94 |
+
# --- GENERATE CONFIG ONLY IF MISSING ---
|
| 95 |
+
if [ ! -f "$OPENCLAW_DIR/openclaw.json" ]; then
|
| 96 |
+
echo "[CFG] Generating initial openclaw.json"
|
| 97 |
+
|
| 98 |
+
if [ -z "$GEMINI_APIKEY" ]; then
|
| 99 |
+
echo "ERROR: GEMINI_APIKEY not set"
|
| 100 |
+
exit 1
|
| 101 |
+
fi
|
| 102 |
+
|
| 103 |
+
cat > "$OPENCLAW_DIR/openclaw.json" << EOC
|
| 104 |
+
{
|
| 105 |
+
"env": {
|
| 106 |
+
"GOOGLE_API_KEY": "${GEMINI_APIKEY}",
|
| 107 |
+
"GEMINI_API_KEY": "${GEMINI_APIKEY}",
|
| 108 |
+
"GOOGLE_GENERATIVE_AI_API_KEY": "${GEMINI_APIKEY}",
|
| 109 |
+
"TELEGRAM_BOT_TOKEN": "${TELEGRAM_BOT_TOKEN}"
|
| 110 |
+
},
|
| 111 |
+
"gateway": {
|
| 112 |
+
"mode": "local",
|
| 113 |
+
"bind": "lan",
|
| 114 |
+
"port": 7860,
|
| 115 |
+
"trustedProxies": ["0.0.0.0/0"],
|
| 116 |
+
"auth": {
|
| 117 |
+
"mode": "token",
|
| 118 |
+
"token": "${OPENCLAW_GATEWAY_PASSWORD}"
|
| 119 |
+
},
|
| 120 |
+
"controlUi": { "allowInsecureAuth": true }
|
| 121 |
+
},
|
| 122 |
+
"models": {
|
| 123 |
+
"providers": {
|
| 124 |
+
"nvidia": {
|
| 125 |
+
"baseUrl": "https://integrate.api.nvidia.com/v1",
|
| 126 |
+
"apiKey": "${NVIDIA_NIM_API_KEY}",
|
| 127 |
+
"api": "openai-completions",
|
| 128 |
+
"models": [
|
| 129 |
+
{ "id": "deepseek-ai/deepseek-r1-distill-qwen-7b", "name": "Deepseek R1 Distill Qwen 7b", "contextWindow": 200000, "maxTokens": 8192 },
|
| 130 |
+
{ "id": "deepseek-ai/deepseek-v3.2", "name": "Deepseek v3.2", "contextWindow": 200000, "maxTokens": 8192 },
|
| 131 |
+
{ "id": "openai/gpt-oss-120b", "name": "GPT OSS 120b", "contextWindow": 200000, "maxTokens": 8192 },
|
| 132 |
+
{ "id": "openai/gpt-oss-20b", "name": "GPT OSS 20b", "contextWindow": 200000, "maxTokens": 8192 },
|
| 133 |
+
{ "id": "qwen/qwen2.5-7b-instruct", "name": "Qwen 2.5 7B Instruct", "contextWindow": 200000, "maxTokens": 8192 },
|
| 134 |
+
{ "id": "qwen/qwen2.5-coder-32b-instruct", "name": "Qwen 2.5 Coder 32B", "contextWindow": 200000, "maxTokens": 8192 },
|
| 135 |
+
{ "id": "qwen/qwen2.5-coder-7b-instruct", "name": "Qwen 2.5 Coder 7B", "contextWindow": 200000, "maxTokens": 8192 },
|
| 136 |
+
{ "id": "mistralai/mistral-large-2-instruct", "name": "Mistral Large 2 Instruct", "contextWindow": 200000, "maxTokens": 8192 },
|
| 137 |
+
{ "id": "databricks/dbrx-instruct", "name": "DBRX Instruct", "contextWindow": 200000, "maxTokens": 8192 },
|
| 138 |
+
{ "id": "mistralai/mistral-7b-instruct-v0.3", "name": "Mistral 7B Instruct v0.3", "contextWindow": 200000, "maxTokens": 8192 },
|
| 139 |
+
{ "id": "minimaxai/minimax-m2.1", "name": "MiniMax M2.1", "contextWindow": 200000, "maxTokens": 8192 },
|
| 140 |
+
{ "id": "z-ai/glm4.7", "name": "GLM 4.7", "contextWindow": 200000, "maxTokens": 8192 }
|
| 141 |
+
]
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
},
|
| 145 |
+
"agents": {
|
| 146 |
+
"defaults": {
|
| 147 |
+
"model": {
|
| 148 |
+
"primary": "google/gemini-3-flash-preview",
|
| 149 |
+
"fallbacks": [
|
| 150 |
+
"google/gemini-3-pro-preview",
|
| 151 |
+
"google/gemini-2.0-flash",
|
| 152 |
+
"google/gemini-2.5-flash",
|
| 153 |
+
"google/gemini-2.5-pro",
|
| 154 |
+
"google/gemini-3-flash-preview"
|
| 155 |
+
]
|
| 156 |
+
},
|
| 157 |
+
"models": {
|
| 158 |
+
"google/gemini-3-pro-preview": {},
|
| 159 |
+
"google/gemini-2.0-flash": {},
|
| 160 |
+
"google/gemini-2.5-flash": {},
|
| 161 |
+
"google/gemini-2.5-pro": {},
|
| 162 |
+
"google/gemini-3-flash-preview": {},
|
| 163 |
+
"nvidia/deepseek-ai/deepseek-r1-distill-qwen-7b": {},
|
| 164 |
+
"nvidia/deepseek-ai/deepseek-v3.2": {},
|
| 165 |
+
"nvidia/openai/gpt-oss-120b": {},
|
| 166 |
+
"nvidia/openai/gpt-oss-20b": {},
|
| 167 |
+
"nvidia/qwen/qwen2.5-7b-instruct": {},
|
| 168 |
+
"nvidia/qwen/qwen2.5-coder-32b-instruct": {},
|
| 169 |
+
"nvidia/qwen/qwen2.5-coder-7b-instruct": {},
|
| 170 |
+
"nvidia/mistralai/mistral-large-2-instruct": {},
|
| 171 |
+
"nvidia/mistralai/mistral-7b-instruct-v0.3": {},
|
| 172 |
+
"nvidia/databricks/dbrx-instruct": {},
|
| 173 |
+
"nvidia/minimaxai/minimax-m2.1": {},
|
| 174 |
+
"nvidia/z-ai/glm4.7": {}
|
| 175 |
+
},
|
| 176 |
+
"workspace": "/root/.openclaw/workspace",
|
| 177 |
+
"compaction": { "mode": "safeguard" },
|
| 178 |
+
"maxConcurrent": 4,
|
| 179 |
+
"subagents": { "maxConcurrent": 8 }
|
| 180 |
+
}
|
| 181 |
+
},
|
| 182 |
+
"commands": {
|
| 183 |
+
"native": "auto",
|
| 184 |
+
"nativeSkills": "auto",
|
| 185 |
+
"restart": true
|
| 186 |
+
},
|
| 187 |
+
"plugins": {
|
| 188 |
+
"entries": {
|
| 189 |
+
"telegram": {
|
| 190 |
+
"enabled": true
|
| 191 |
+
},
|
| 192 |
+
"whatsapp": {
|
| 193 |
+
"enabled": false
|
| 194 |
+
},
|
| 195 |
+
"discord": {
|
| 196 |
+
"enabled": false
|
| 197 |
+
},
|
| 198 |
+
"qwen-portal-auth": {
|
| 199 |
+
"enabled": false
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
},
|
| 203 |
+
"channels": {
|
| 204 |
+
"telegram": {
|
| 205 |
+
"enabled": true,
|
| 206 |
+
"allowFrom": ["${TELEGRAM_USER}"]
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
EOC
|
| 211 |
+
fi
|
| 212 |
+
|
| 213 |
+
chmod -R 700 "$OPENCLAW_DIR"
|
| 214 |
+
|
| 215 |
+
# --- BACKUP LOOP (EVERY 5 MINUTES) ---
|
| 216 |
+
if [[ -n "$HF_DATASET_TOKEN" && -n "$HF_DATASET" ]]; then
|
| 217 |
+
(
|
| 218 |
+
while true; do
|
| 219 |
+
sleep 300
|
| 220 |
+
echo "[HF] Backup running"
|
| 221 |
+
|
| 222 |
+
python3 << 'EOP'
|
| 223 |
+
import os
|
| 224 |
+
from huggingface_hub import HfApi
|
| 225 |
+
|
| 226 |
+
api = HfApi(token=os.environ["HF_DATASET_TOKEN"])
|
| 227 |
+
api.upload_folder(
|
| 228 |
+
repo_id=os.environ["HF_DATASET"],
|
| 229 |
+
repo_type="dataset",
|
| 230 |
+
folder_path="/root/.openclaw",
|
| 231 |
+
path_in_repo="data",
|
| 232 |
+
ignore_patterns=[
|
| 233 |
+
"openclawd.json",
|
| 234 |
+
"agents/**/sessions/**",
|
| 235 |
+
"workspace/node_modules/**",
|
| 236 |
+
"browser/**",
|
| 237 |
+
"workspace/.cache/**",
|
| 238 |
+
"*.key",
|
| 239 |
+
".env"
|
| 240 |
+
]
|
| 241 |
+
)
|
| 242 |
+
print("[HF] Backup complete")
|
| 243 |
+
EOP
|
| 244 |
+
done
|
| 245 |
+
) &
|
| 246 |
+
fi
|
| 247 |
+
|
| 248 |
+
exec openclaw gateway run --port 7860
|
| 249 |
+
EOF
|
| 250 |
+
|
| 251 |
+
RUN chmod +x /usr/local/bin/start-openclaw
|
| 252 |
+
CMD ["/usr/local/bin/start-openclaw"]
|