claw / Dockerfile
1u's picture
Update Dockerfile
de293c1 verified
FROM node:22-slim
ENV DEBIAN_FRONTEND=noninteractive
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-venv git && \
python3 -m venv $VIRTUAL_ENV && \
pip install --no-cache-dir huggingface_hub && \
rm -rf /var/lib/apt/lists/*
COPY sync_data.py /app/sync_data.py
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Install OpenClaw globally
RUN npm install -g openclaw@latest
# Create config directory
RUN mkdir -p /root/.openclaw
# Set up environment for Hugging Face Spaces
ENV PORT=7860
ENV GATEWAY_MODE=local
# Expose the port (Hugging Face default)
EXPOSE 7860
# Create a startup script that generates config and starts OpenClaw
RUN cat <<'EOF' > /usr/local/bin/start-openclaw
#!/bin/bash
set -x
# Create critical missing directories
mkdir -p /root/.openclaw/agents/main/agent
mkdir -p /root/.openclaw/agents/main/sessions
mkdir -p /root/.openclaw/credentials
# Remove auth-profiles.json if it exists to force env var usage
rm -f /root/.openclaw/agents/main/agent/auth-profiles.json
# Generate minimal config if not exists
if [ ! -f /root/.openclaw/openclaw.json ]; then
cat <<JSON > /root/.openclaw/openclaw.json
{
"env": {
},
"gateway": {
"mode": "local",
"bind": "lan",
"port": ${PORT},
"trustedProxies": ["0.0.0.0/0"],
"auth": {
"mode": "token",
"token": "${GATEWAY_AUTH_TOKEN}"
},
"controlUi": {
"allowInsecureAuth": true
}
},
"agents": {
"defaults": {
"model": {
"primary": "nvidia/minimaxai/minimax-m2.1"
}
}
},
"models": {
"providers": {
"nvidia": {
"baseUrl": "https://integrate.api.nvidia.com/v1",
"apiKey": "${MOONSHOT_API_KEY}",
"api": "openai-completions",
"models": [{ "id": "minimaxai/minimax-m2.1", "name": "minimax-m2.1" }]
}
}
},
"channels": {
"telegram": {
"enabled": true,
"botToken": "${TG_BOT_TOKEN}",
"dmPolicy": "pairing"
}
}
}
JSON
fi
# Fix permissions
chmod 700 /root/.openclaw
chmod 600 /root/.openclaw/openclaw.json || true
chmod 600 /root/.openclaw/agents/main/agent/auth-profiles.json || true
# Fix config if needed
openclaw doctor --fix
# Start OpenClaw gateway
echo "Starting OpenClaw gateway on port ${PORT}..."
exec openclaw gateway run --port ${PORT}
EOF
RUN chmod +x /usr/local/bin/start-openclaw
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/usr/local/bin/start-openclaw"]